Skip to Content
0
Former Member
Oct 20, 2005 at 12:08 PM

Row Addition

14 Views

hi please correct this...

i wanted to add the rows of netpr and nerwr...i wanted to show the total as a new field...i have done but not coming the result..

EPORT ZKAGTB .

TABLES: vbap, vbak, MARA, mbew , KNA1.

type-pools: slis. "ALV Declarations

data : BEGIN OF itabVBAK occurs 0,

matnr type mara-matnr,

-


-


NETWR type vbap-netwr,

BATOT LIKE VBAP-NETPR, <b>(new field)</b>

NAME1 type kna1-name1,

end of itabvbak.

data: batot like VBAP-NETPR.

data: fieldcatalog type slis_t_fieldcat_alv with header line,

gd_tab_group type slis_t_sp_group_alv,

gd_layout type slis_layout_alv,

gd_repid like sy-repid,

gt_events type slis_t_event,

gd_prntparams type slis_print_alv.

START-OF-SELECTION.

perform data_retrieval.

perform build_fieldcatalog.

perform build_layout.

perform build_events.

perform build_print_params.

perform display_alv_report.

endform. " BUILD_FIELDCATALOG

form build_fieldcatalog.

DEFINE m_fieldcat.

add 1 to ls_fieldcat-col_pos.

ls_fieldcat-fieldname = &1.

ls_fieldcat-ref_tabname = &2.

append ls_fieldcat to lt_fieldcat.

END-OF-DEFINITION.

fieldcatalog-fieldname = 'VBELN'.

-


-


-


-


-


fieldcatalog-fieldname = 'BATOT'.

fieldcatalog-seltext_m = 'BALANCE'.

fieldcatalog-col_pos = 11.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

endform. " BUILD_FIELDCATALOG

form build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-totals_text = 'Totals'(201).

gd_layout-totals_only = 'X'.

gd_layout-info_fieldname = 'LINE_COLOR'.

gd_layout-info_fieldname = 'WS_COLOR'.

gd_layout-zebra = 'X'.

endform. " BUILD_LAYOUT

form display_alv_report.

gd_repid = sy-repid.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = gd_repid

i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM

i_callback_user_command = 'USER_COMMAND'

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

it_events = gt_events

is_print = gd_prntparams

i_save = 'X'

tables

t_outtab = itabvbak

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.

endform. " DISPLAY_ALV_REPORT

form data_retrieval.

data: ld_color(1) type C.

select mara~matnr

-


-


-


KNA1~name1

into corresponding fields of table itabvbak from VBAP

inner join VBAK

on VBAPvbeln = VBAKvbeln

inner join mara

on VBAPmatnr = maramatnr

inner join mbew

on VBAPmatnr = mbewmatnr

inner join KNA1

on VBAKKUNNR = KNA1KUNNR

where VBAK~kunnr in s_kunn1

<b>LOOP AT ITABVBAK.

READ TABLE ITABVBAK WITH KEY VBELN = VBAP-VBELN.

IF SY-SUBRC = 0.

ITABVBAK-BATOT = ITABVBAK-NETPR + ITABVBAK-NETWR.

ENDIF.

ENDLOOP.

endform. " DATA_RETRIEVAL</b>

can u correct this..

raju

Message was edited by: mpr raju