2013 Nov 18 10:10 AM
Please tell me
Can you tell how to put event at end of in loop of Dynamic internal Table
Loop at <internal table > assigning <work area>
at end < how to give field name please write it here >
end at
endloop .
2013 Nov 18 10:20 AM
Hi Alok,
Please write a code below and check.
Loop at <internal table > assigning <work area>
at end internal table fieldname.
For Eg:- at end of carrid.
end at
endloop .
Arivazhagan S
2013 Nov 18 10:24 AM
I am not able to give field name from dyanmic Internal Table like Carrid .
Loop at <internal table > assigning <work area>
at end internal table fieldname.
For Eg:- at end of carrid( How to give that field name from Dynamic Internal Table).
end at
endloop .
2013 Nov 18 10:36 AM
Hi Alok,
I think it will be helpful to you..
First you declare a variable with the type carrid & assign <work area> field to it as shown below.
data : l_carrid type sflight-carrid.
loop at <internal table> assigning <work area>
assign component 'CARRID' of structure <work area> to l_carrid.
at end of l_carrid.
endat.
endloop.
Be careful when you clear assigned variable l_carrid .
Thanks,
Raghu
2013 Nov 18 10:42 AM
Field not define error and sum and You cannot use the "SUM" statement inside "LOOP ... ASSIGNING ...". error
2013 Nov 18 10:46 AM
Hi Alok,
Can i have the Code what you exactly written.
Thanks
Raghu
2013 Nov 18 10:54 AM
yes ,
LOOP AT <gfs_dyn_table> INTO <gfs_line>.
INDEX = 1 .
ASSIGN COMPONENT INDEX OF STRUCTURE <GFS_LINE> TO <gfs_line>.
AT END OF <FS1>.
SUM.
ENDAT.
ENDLOOP.
2013 Nov 18 11:04 AM
field-symbols : <f1> type any.
data : l_carrid type sflight-carrid.
LOOP AT <gfs_dyn_table> INTO <gfs_line>.
ASSIGN COMPONENT 'CARRID' OF STRUCTURE <GFS_LINE> TO <F1>.
l_carrid = <f1>.
AT END OF l_carrid.
SUM.
ENDAT.
ENDLOOP.
Yes, We can not use Sum in dynamic Internal Table. Instead u can take one more Field symbol like line of <gfs_dyn_table>, add into it every time.
Hope, it works for u.
Thanks,
Raghu
2013 Nov 18 11:28 AM
2013 Nov 18 11:26 AM
at end < how to give field name please write it here >
Do you know the name of the field to be used here for the at end statement?
2013 Nov 18 11:38 AM
yes
I now the field name . i throw error that is sum not working in Assigning
2013 Nov 18 12:39 PM
At end 'field' is not working (or) sum is not working.
You want Sum at the end of that field carrid ?
2013 Nov 19 2:03 AM
2013 Nov 19 2:05 AM
Madam I don't how to give field name
at end of event so that's why I ask you please sort out that issue
2013 Nov 19 6:11 AM
If you know the name of the column then just add it to the sort table, and pass it your ALV.
2013 Nov 19 3:28 AM
Hi Alok,
for this dyn table, you will be storing the field names some where right.
lets say lv_field contains the field name.
try this <wa>-(lv_field).
Thanks and Regards,
bhaskar
2013 Nov 19 4:29 AM
Hi Alok,
You cannot use the sum statement inside an assigning loop.Since it is an dynamic internal table you have to use assign component and add the fields to a variable.
LOOP AT <itab> ASSIGNING <wa>.
ASSIGN COMPONENT '<field>' OF STRUCTURE <wa> TO <comp>.
IF sy-subrc EQ 0.
ADD <comp> TO total.
ENDIF.
ENDLOOP.
Regards,
Jeffin
2013 Nov 19 4:36 AM
2013 Nov 19 4:45 AM
2013 Nov 19 5:01 AM
K fine.. Fallow as shown below.
If you want Sub total at the end of carrid, fill fieldcat for carrid as shown below.
If you use lvc type fieldcat.
CLEAR gw_fieldcat.
gw_fieldcat-fieldname = 'CARRID'.
gw_fieldcat-tabname = 'ITAB'.
gw_fieldcat-seltext_l = 'Airline Code'.
gw_fieldcat-col_pos = 1. -------> as in your report column
gw_fieldcat-outputlen = 7.
gw_fieldcat-do_sum = 'X'.
APPEND gw_alv_fieldcat TO gt_alv_fieldcat.
fill sort internal table
lt_Sort type lvc_t_sort.
wa_sort type lvc_s_sort.
CLEAR WA_SORT.
WA_SORT-FIELDNAME = 'CARRID'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO LT_SORT.
Use reuse_alv_grid_display_lvc.
pass sort Internal table to it
as IT_SORT_LVC = LT_SORT..
Remove at the end of Code..
2013 Nov 19 5:04 AM
Hi,
Create an internal table of type LVC_T_FCAT and mark the option do_sum as 'X' and LVC_T_SORT and mark the option subtot as 'X' for the field you required. and pass these internal tables to the method SET_TABLE_FOR_FIRST_DISPLAY.
Please refer this link
2013 Nov 20 9:07 AM
2013 Nov 20 11:27 AM
Hello Alok,
Please try below code, but you try to sum the value that is stored inside the field symbol but it is working like a pointer(it points the address) then in mean time the loop comes in to picture the address is over write with current record value so that is the reason SAP Doesn't support for the field symbol summation in LOOP. please find the below program it helps you let me know.
REPORT ZFIELD_SYMBOL.
types :
BEGIN OF ty_vbap,
vbeln TYPE vbeln_va,
posnr TYPE posnr_Va,
netwr TYPE netwr_ap,
END OF ty_vbap,
ty_tbl_vbap TYPE STANDARD TABLE OF ty_vbap.
data :
gt_vbap TYPE ty_tbl_vbap,
gs_vbap TYPE ty_vbap,
gv_netwr TYPE netwr_ap.
FIELD-SYMBOLS:
<ft_vbap> TYPE ty_tbl_vbap,
<fs_vbap> TYPE ty_vbap.
SELECT-OPTIONS :
so_vbeln for <fs_vbap>-vbeln OBLIGATORY.",
* sd_vbeln FOR gs_vbap-vbeln.
START-OF-SELECTION.
SELECT vbeln posnr netwr
INTO TABLE gt_vbap
FROM vbap
WHERE vbeln in so_vbeln.
end-of-SELECTION.
ASSIGN gt_vbap to <ft_vbap>.
WRITE :/ 'Sales Dno'(010), 'Item No'(006), 'Amount'."<fs_vbap>-zwert.
loop at <ft_vbap> ASSIGNING <fs_vbap>.
WRITE :/ <fs_vbap>-vbeln(010), <FS_VBAP>-POSNR(6), <fs_vbap>-netwr.
gv_netwr = <fs_vbap>-netwr + gv_netwr.
at END of vbeln.
WRITE:/'*************************************', gv_netwr.
CLEAR gv_netwr.
ENDAT.
ENDLOOP.
Regards
Sudhakar