Sum function for internal table column
Dear Experts,
how can I sum a complete internal table column.
Regards
ertas
Hi,
Use SUM in AT END of event in the loop of an internal table.
Example
Loop at ITAB into wa_itab.
at end of wa_itab-field.
sum. " Here all numric fields will be summed and stored in that filed(wa_itab-field)
endat.
Endloop.
Regards
Krishna
Similar Messages
-
Aggregate functions for internal table.
Hi Gurus,
I'm just wondering whether we can use aggregate functions for internal table. I wanted to know the max value for a particular column in my internal table. How can I achieve this easily and quickly.
Thanks,
David.sort the table on which you want the maximum value and read it. Please find below example code.
TYPES : BEGIN OF ty_mvke,
matnr TYPE mvke-matnr,
vkorg TYPE mvke-vkorg,
vtweg TYPE mvke-vtweg,
AUMNG type mvke-AUMNG,
END OF ty_mvke.
DATA : wa_mvke TYPE ty_mvke,
it_mvke TYPE STANDARD TABLE OF ty_mvke.
data : temp_AUMNG type AUMNG.
START-OF-SELECTION.
SELECT matnr vkorg vtweg AUMNG FROM mvke INTO
table it_mvke.
sort it_mvke by AUMNG.
read TABLE it_mvke into wa_mvke INDEX 1.
if sy-subrc = 0.
move wa_mvke-AUMNG to temp_AUMNG.
write : temp_AUMNG.
endif.
Thanks,
Sreekala. -
How to use aggregate function on internal table
hi experts,
I am beginner in abap.I want to use sum function on internal table.
I have structure as follow:
types: begin of ty_ftab,
docno TYPE bkpf-belnr,
comcode TYPE bkpf-bukrs,
year TYPE bkpf-gjahr,
line_itm type bsad-buzei,
cust type bsad-kunnr,
amt type bsad-dmbtr,
end of ty_ftab.
data: it_ftab type table of ty_ftab,
wa_ftab type ty_ftab.
i fetched data successfully into it_ftab from bkpf and bsad table and displyed into alv.
now i want sum of amt using group by cust and want to display like
cust total_amt
in next screen...
displying part is not important but how can i do sum of amt according to cust value? Is there in way to query on internal table?Hi,
try this code,
data : i_sort TYPE TABLE OF slis_sortinfo_alv
w_sort like LINE OF i_sort.
sort it_ftab by cust.
w_sort-subtot = 'X'.
w_sort-fieldname = 'AMT'.
w_sort-tabname = 'it_ftab'.
APPEND w_sort to i_sort.
In fieldcatalog :
w_fcat-fieldname = 'AMT'.
w_fcat-tabname = 'it_ftab'.
w_fcat-do_sum = 'X'.
In REUSE_ALV_GRID_DISPLAY FUNCTION MODULE provide the it_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
* EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
* I_CALLBACK_PROGRAM = ' '
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
* IT_FIELDCAT =
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
IT_SORT = i_sort
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab =
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF. -
Data allocation for internal table rows Dynamically
Hi Friends
I have requirement like below:
I have one internal table with 400 amounts columns, I will get the value from another program
that indicates to which column I have to add the values. I dont want to write the case statement
because I need to write 400 WHEN statements.
Is there any alternative way dynamically I can choose the internal table column and assign the value which
I am getting from external program.
Please help on this as soon as possible.
Points will be rewarded
Thanks
PraveenHi Praveen,
you may use the ASSIGN COMPONENT ... OF STRUCTURE ... statement.
It allows to assign the field by name or by sequence.
Assume you columns have names like amount_001 to amount_999 and are fields of structure ls_amounts. The do as decribed here roughly:
data:
lv_fieldseq type NUMC_3,
lv_fieldname type fieldname,
lv_amount type (???).
fieldsymbols:
<amount> type any.
* fetch amount and field sequence from external data into lv_amount and lv_fieldseq
concatenate 'AMOUNT_' lv_fieldseq into lv_fieldname.
* <amount> is something like a pointer
assign component (lv_fieldname) of structure ls_amounts to <amount>.
add lv_amount to <amount>.
if you are sure you have the correct position of the amount field in the structure stored in variable lv_position, you may use
assign component lv_position of structure ls_amounts to <amount>.
I prefer the ASSIGN (fieldname) for reasons of more transparency and less danger in case of structural changes.
Regards,
Clemens
Regards,
Clemens -
Open cursor for internal table
Hi folks,
I have a tricky question concerning the cursor function and internal tables. First of all, it is not possible to create a view. Instead I've to use a function module for extracting some data to the BI system.
Actually most of the time I work with SELECT (for outer joins) and internal tables. At the end I have a internal table and must open an cursor. As fact, I can't open a cursor for an internal table - only database tables are allowed.
OPEN CURSOR WITH HOLD s_cursor FOR SELECT * FROM lt_temp.
Does someone have a clue how to solve my problem? Obviously I have to use a db table for a open cursor statement but on the same way I have to use a internal table for all my previous SELECT-statements.
Thanks in advance for your help.
Regards,
MrclWhy don't you use EXEC and ENDEXEC
Check this link
http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3b8b358411d1829f0000e829fbfe/content.htm
a® -
Using Alias for the table column
Dear all,
Can we use alias name for the table column while developing zreport.
ie.,
without using standard table column name ( like mara-matnr ), i wish to use mat_num for matnr. So that, one can easily understand the column.
Could you help me out in this regard.
Thanks in Advance,
S.Sridhar.yes you can declare in ur internal table like
material_number like mara-matnr. -
Why using workarea for internal table is better in performance
Please tell me
why using workarea for internal table is better in performanceHi Vineet ,
Why would we choose to use an internal table without a header line when it is easier to code one with a header line?
it has following reason.
1)Separate Internal Table Work Area:
The work area (staging area) defined for the internal table is not limited to use with just one internal table.
take ex-
Suppose you want two internal tables for EMPLOYEE one to contain all records and one to contain only those records where country = USA. You could create both of these internal tables without header lines and use only one work area to load data into both of them. You would append all records from the work area into the first internal table. You would conditionally append the USA records from the same work area into the second internal table.
2) Performance Issues: Using an internal table without a header line is more efficient than one with a header line
3) Nested Internal Tables: If you want to include an internal table within a structure or another internal table, you must use one without a header line.
If this one is helpful ,then rewards me
Regards
Shambhu -
System Variable For Internal table count
Can anybody tell me what the system variable for internal table count?
I just wants to know how many recoreds are there in my internal table ?
Regards,
pandu.Hi ,
DESCRIBE TABLE <itab> [LINES <l>] [OCCURS <n>] [KIND <k>].
If you use the LINES parameter, the number of filled lines is written to the variable <lin>. If parameter, the you use the OCCURS value of the INITIAL SIZE of the table is returned to the variable <n>. If you use the KIND parameter, the table type is returned to the variable <k>: T for standard table, S for sorted table, and H for hashed table.
using variable
SY-TFILL
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TFILL contains the number of lines in the relevant internal table.
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3798358411d1829f0000e829fbfe/content.htm
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Feb 21, 2008 4:53 PM -
How to create Function Module with TABLE parameter (for internal table)
Hi Guys,
I am trying to create a function module by using TABLE parameter. I have to pass an internal table to this function module for processing.
But it saying : TABLES parameters are obsolete!
And I am not going further.
Please suggest any work arround.
ThanksHi,
create a table type in SE11..
Then use that in your function module importing/exporting/changing parameter for passing internal tables..
Thanks,
Naren -
ALV - need to sum values of internal table and display in ALV
I have data in internal table as:
Material date sum1 sum2
Mat_A 19990101 4 4
Mat_A 20080501 3 0
Mat_A 20080601 2 0
Mat_B 19990101 2 0
Mat_B 20080601 5 5
Required output is :
Material qty1 qty2 19990101 20080501 20080601
Mat_A 432 4 4 3 2
Mat_B 2+5 5 2 5
Thinking of using ALV to pass the internal table and display as classical report (and also to save as excel spreadsheet).
Counting your help on the following questions:
1) How to accomplish the sum in ALV report? Can ALV FM do that or one has to use ABAP to compute the sum from the given internal table?
2) Mat_A can have more date values. Here it got 3 distinct date values 19990101, 20080601, 20080501. If it has say 5 date values, how to create the ALV date columns (from 3 to 5 date columns) dynamically?
Thanks for the help.for the sum inalv we use generally..
it_fieldcat-do_sum = 1.
check this examples...
http://www.****************/Tutorials/ALV/Subtotals/text.htm
*& Report ZTEST_ALV_PERC_13317
REPORT ztest_alv_perc_13317.
TYPE-POOLS: slis.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
it_events TYPE slis_t_event,
wa_events TYPE slis_alv_event,
it_sort TYPE slis_t_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv,
l_layout TYPE slis_layout_alv.
TYPES: BEGIN OF ty_itab,
field1(10),
qty1 TYPE i,
qty2 TYPE i,
qty3 TYPE i,
dummy TYPE c,
END OF ty_itab.
DATA: itab TYPE STANDARD TABLE OF ty_itab WITH HEADER LINE,
itab1 TYPE ty_itab.
START-OF-SELECTION.
itab-field1 = 'FIRST'.
itab-qty1 = 2.
itab-qty2 = 1.
itab-qty3 = 5.
itab-dummy = 10.
APPEND itab.
itab-field1 = 'FIRST'.
itab-qty1 = 2.
itab-qty2 = 1.
itab-qty3 = 5.
itab-dummy = 10.
APPEND itab.
itab-field1 = 'FIRST'.
itab-qty1 = 2.
itab-qty2 = 1.
itab-qty3 = 5.
itab-dummy = 10.
APPEND itab.
wa_fieldcat-col_pos = 1.
wa_fieldcat-fieldname = 'FIELD1'.
wa_fieldcat-tabname = 'ITAB'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-col_pos = 2.
wa_fieldcat-fieldname = 'QTY1'.
wa_fieldcat-tabname = 'ITAB'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-col_pos = 3.
wa_fieldcat-fieldname = 'QTY2'.
wa_fieldcat-tabname = 'ITAB'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-col_pos = 4.
wa_fieldcat-fieldname = 'QTY3'.
wa_fieldcat-tabname = 'ITAB'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-col_pos = 5.
wa_fieldcat-fieldname = 'DUMMY'.
wa_fieldcat-tabname = 'ITAB'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-no_out = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = it_events
EXCEPTIONS
list_type_wrong = 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.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_fieldcat
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2
IF sy-subrc <> 0.
ENDIF. -
Using aggregation in ABAP code for internal table
I have written following code to get cumulative amount on a date but i have to hit database for each record.
Can't I use some function similar to SUM for doing the same thing on internal table??It would increase my performance.
code is:
SELECT SUM( DEB_CRE_LC ) FROM /BIC/AZFIAR_O500
INTO LV_BALMONTH WHERE DEBITOR = LV_DEBITOR AND
CALMONTH GE LV_STARTMONTH AND CALMONTH LE LV_LASTCALMON.
I want to put ZFIAR data to internal table and read and do SUM thing..is it possible?? withotut usiong loop.
regards,
rakeshHi Rajesh,
types : begin of ty_tab,
date type dats,
DEB_CRE_LC type ..... " delare type & is the filed need to summerized
end of ty_tab,
data: itab type standard table of ty_tab.
SELECT date
SUM( DEB_CRE_LC ) as DEB_CRE_LC FROM /BIC/AZFIAR_O500
INTO corresponding fields of itab
where CALMONTH GE LV_STARTMONTH AND CALMONTH LE LV_LASTCALMON
group by date. " date is the field available in your ODS/transparent table
simulate the above code in your program...
Hope this will work.. -
SELECT-OPTIONS sel FOR Internal Table
Hello,
I would like to use select-options. Normally you can specify a selection tab (sel) and a row of an table being registered in the ABAP dictionary.
I would like to use an internal table instead.
First I read data into the internal table. Next I would refer on one column of that internal using the select-options:
SELECT * FROM database-tab INTO itab
WHERE key1 = 'a'.
SELECT-OPTIONS: sel FOR itab.
It does not work, although the internal table is filled!!!
Can I use internal tables with select-options?
thx, holgerHallo Holger,
i think i get it now - thanks Amit !
here's an example:
AT SELECTION-SCREEN ON VALUE-REQUEST FOR matnr-low.
SELECT matnr maktg FROM m_mat1t
INTO CORRESPONDING FIELDS OF TABLE f4_itab
WHERE mtart = 'DIEN'.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'MATNR'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'MATNR'
window_title = 'select material no.'
value_org = 'S'
TABLES
value_tab = f4_itab[].
Andreas -
Hi Gurus,
I want to print sum of a particular coloumn in dynamic internal table,
But in Field symbold use char type so i cant able to print sum.
help me to solve this problem.
Regards,
Bhuvana.Hi
Herwith i attach my code.
*& Report ZFR133_TELECAST_REVENUE *
REPORT zfr133_telecast_revenue .
MODULE xxxxxxxx. *
Objective :.......................................... *
Program : Updates Tables ( ) Downloads data ( ) *
Outputs List ( ) *
Technical Spec No ............... *
Date Created 17/09/2008 *
Author J.Bhuvaneswari *
Location SUN TV / Chennai *
LDB ..... *
External Dependencies *
Amendment History *
Who Change ID Reason *
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ *
XXXXXXXXX AADDMMYYYY Where XXXX = Developers Name................. *
AA- Developers Initial ................................ *
Includes *
*INCLUDE : *
Tables *
TABLES : t001, bkpf, csks, bseg, cskt.
Types Begin with TY_ *
TYPES : BEGIN OF ty_bkpf,
bukrs LIKE bkpf-bukrs,
belnr LIKE bkpf-belnr,
gjahr LIKE bkpf-gjahr,
monat LIKE bkpf-monat,
stblg LIKE bkpf-stblg,
END OF ty_bkpf,
BEGIN OF ty_bseg,
bukrs LIKE bseg-bukrs,
gjahr LIKE bseg-gjahr,
belnr LIKE bseg-belnr,
shkzg LIKE bseg-shkzg,
dmbtr LIKE bseg-dmbtr,
kostl LIKE bseg-kostl,
hkont LIKE bseg-hkont,
END OF ty_bseg,
BEGIN OF ty_cskt,
kostl LIKE cskt-kostl,
ltext LIKE cskt-ltext,
END OF ty_cskt,
BEGIN OF ty_temp,
belnr LIKE bseg-belnr,
monat LIKE bkpf-monat,
kostl LIKE cskt-kostl,
ltext LIKE cskt-ltext,
shkzg LIKE bseg-shkzg,
dmbtr LIKE bseg-dmbtr,
END OF ty_temp.
DATA: BEGIN OF ty_stru OCCURS 0,
kostl LIKE cskt-kostl,
monat LIKE bkpf-monat,
dmbtr LIKE bseg-dmbtr,
END OF ty_stru.
Constants Begin with C_ *
*CONSTANTS: *
Data Begin with W_ *
DATA : w_amt LIKE bseg-dmbtr,
w_var TYPE string,
w_text TYPE string,
w_value TYPE i,
w_cnt TYPE i VALUE 1,
w_mon TYPE month,
okcode TYPE sy-ucomm.
Infotypes ( HR Module Specific) *
*INFOTYPES : *
Internal tables Begin with IT_ *
DATA : it_bkpf TYPE TABLE OF ty_bkpf,
it_bseg TYPE TABLE OF ty_bseg,
it_cskt TYPE TABLE OF ty_cskt,
it_temp TYPE TABLE OF ty_temp,
it_tmp1 TYPE TABLE OF ty_temp,
it_tmp2 TYPE TABLE OF ty_temp,
it_ccen TYPE TABLE OF ty_temp,
it_monat TYPE TABLE OF ty_temp.
DATA : xfc TYPE lvc_s_fcat,
ifc TYPE lvc_t_fcat,
ty_lay TYPE lvc_s_layo,
dy_table TYPE REF TO data,
dy_line TYPE REF TO data.
DATA : cl TYPE REF TO cl_gui_custom_container,
cl_alv TYPE REF TO cl_gui_alv_grid.
DATA : wa_bkpf TYPE ty_bkpf,
wa_bseg TYPE ty_bseg,
wa_cskt TYPE ty_cskt,
wa_temp TYPE ty_temp,
wa_tmp1 TYPE ty_temp,
wa_tmp2 TYPE ty_temp,
wa_ccen TYPE ty_temp,
wa_monat TYPE ty_temp,
wa_month TYPE t247.
Field Symbols Begin with FS_ *
*FIELD-SYMBOLS: *
FIELD-SYMBOLS: .
Insert *
*INSERT : *
Select Options Begin with SO_ *
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
PARAMETERS : pr_bukrs LIKE t001-bukrs OBLIGATORY,
pr_gjahr LIKE bkpf-gjahr OBLIGATORY.
SELECT-OPTIONS : so_monat FOR bkpf-monat OBLIGATORY,
so_kostl FOR bseg-kostl OBLIGATORY,
so_hkont FOR bseg-hkont OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk1.
Parameters Begin with PR_ *
*PARAMETERS : *
Initialisation *
*INITIALIZATION.
At selection-screen *
*AT SELECTION-SCREEN.
S T A R T O F S E L E C T I O N *
START-OF-SELECTION.
******Select data from Header Table.
SELECT bukrs gjahr belnr monat stblg
FROM bkpf INTO CORRESPONDING FIELDS OF TABLE it_bkpf
WHERE bukrs = pr_bukrs AND
gjahr = pr_gjahr AND
monat IN so_monat AND
stblg = ' '.
******Select data from Item Table
IF it_bkpf IS NOT INITIAL.
SELECT bukrs gjahr belnr shkzg dmbtr kostl hkont
FROM bseg INTO CORRESPONDING FIELDS OF TABLE it_bseg
FOR ALL ENTRIES IN it_bkpf
WHERE bukrs = it_bkpf-bukrs AND
gjahr = it_bkpf-gjahr AND
belnr = it_bkpf-belnr AND
kostl IN so_kostl AND
hkont IN so_hkont.
ENDIF.
******Select Cost center text
SELECT kostl ltext
FROM cskt INTO CORRESPONDING FIELDS OF TABLE it_cskt
WHERE spras = 'EN' AND
kokrs = 'SUN1' AND
kostl IN so_kostl.
******Append data in temporary table.
LOOP AT it_bseg INTO wa_bseg.
READ TABLE it_bkpf INTO wa_bkpf WITH KEY belnr = wa_bseg-belnr.
IF sy-subrc = 0.
wa_temp-belnr = wa_bkpf-belnr.
wa_temp-monat = wa_bkpf-monat.
wa_temp-kostl = wa_bseg-kostl.
READ TABLE it_cskt INTO wa_cskt WITH KEY kostl = wa_bseg-kostl.
IF sy-subrc = 0.
wa_temp-ltext = wa_cskt-ltext.
ENDIF.
IF wa_bseg-shkzg = 'H'.
wa_temp-dmbtr = wa_bseg-dmbtr * -1.
ELSE.
wa_temp-dmbtr = wa_bseg-dmbtr.
ENDIF.
APPEND wa_temp TO it_temp.
ENDIF.
ENDLOOP.
SORT it_temp BY kostl monat.
******Internal Table of cost center without duplications.
it_ccen = it_temp.
DELETE ADJACENT DUPLICATES FROM it_ccen COMPARING kostl.
******Internal Table of fiscal period without duplications.
it_monat = it_temp.
SORT it_monat BY monat.
DELETE ADJACENT DUPLICATES FROM it_monat COMPARING monat.
PERFORM dynamic_table.
PERFORM data_upload_dynamic_table.
SET SCREEN 3000.
IF cl IS INITIAL.
CREATE OBJECT cl EXPORTING container_name = 'TC'.
CREATE OBJECT cl_alv EXPORTING i_parent = cl.
ENDIF.
CALL METHOD cl_alv->set_table_for_first_display
EXPORTING
i_structure_name = 'ZALIKP'
is_layout = ty_lay
CHANGING
it_outtab =
it_fieldcatalog = ifc.
*GET XX.
*END-OF-SELECTION.
E N D O F S E L E C T I O N *
At line selection *
*AT LINE-SELECTION.
User Command Processing *
*AT USER-COMMAND.
Top Of Page *
*TOP-OF-PAGE.
End Of Page *
*END-OF-PAGE.
*& Form DYNAMIC_TABLE
FORM dynamic_table .
PERFORM design_fieldcat USING 'KOSTL' 'BSEG' text-002 '10'.
PERFORM design_fieldcat USING 'LTEXT' 'CSKT' text-003 '30'.
LOOP AT it_monat INTO wa_monat.
CONCATENATE 'PE' wa_monat-monat INTO w_text.
w_mon = wa_monat-monat.
CALL FUNCTION 'IDWT_READ_MONTH_TEXT'
EXPORTING
langu = sy-langu
month = w_mon
IMPORTING
t247 = wa_month.
w_var = wa_monat-monat.
w_text = wa_month-ltx.
PERFORM design_fieldcat USING w_var 'BKPF' w_text '10'.
ENDLOOP.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO .
ENDFORM. " DYNAMIC_TABLE
*& Form DESIGN_FIELDCAT
FORM design_fieldcat USING value TYPE string
tab TYPE string
text TYPE string
length TYPE string.
xfc-fieldname = value.
xfc-tabname = tab.
xfc-reptext = text.
xfc-outputlen = length.
APPEND xfc TO ifc.
w_cnt = w_cnt + 1.
CLEAR xfc.
ENDFORM. " DESIGN_FIELDCAT
*& Form DATA_UPLOAD_DYNAMIC_TABLE
FORM data_upload_dynamic_table .
DATA : w_c(2) TYPE c,
w_c1(5) TYPE c,
w_c2(5) TYPE c.
CREATE DATA dy_line LIKE LINE OF .
CLEAR: wa_tmp2,w_amt.
ENDON.
ENDLOOP.
ENDLOOP.
ENDFORM. " DATA_UPLOAD_DYNAMIC_TABLE
*& Module STATUS_3000 OUTPUT
MODULE status_3000 OUTPUT.
SET PF-STATUS 'MENU'.
SET TITLEBAR 'TIT'.
ENDMODULE. " STATUS_3000 OUTPUT
*& Module USER_COMMAND_3000 INPUT
MODULE user_command_3000 INPUT.
CASE okcode.
WHEN 'BACK'." OR 'RW' OR '%EX'.
LEAVE PROGRAM.
CLEAR okcode.
ENDCASE.
ENDMODULE. " USER_COMMAND_3000 INPUT -
Hi All,
I have an internal table as follows.
Now if the KUNNR, PRCTR and VERNA field are similar, i have to sum up the QTY columns accordingly.
I mean to say, in this case, the rows 1, 2 and 3 have same kunnr, prctr and verna fields. Henc ei should sum up the corresponding columns (qty1, qty2, qty3 and SUM) and make it as one row.
kunnr | prctr | verna | qty1 | qty2 | qty3 | sum
11 | 100 | Raj | 10.0 | 5.0 | 0.0 | 15.0
11 | 100 | Raj | 8.0 | 1.0 | 2.0 | 11.0
11 | 100 | Raj | 0.0 | 0.0 | 6.5 | 6.5
12 | 200 | Ram | 2.0 | 0.0 | 0.0 | 2.0
How to carry out this calculation....???
Regards
PavanHi Friend,
Use the Control Break Statement for this, Go through the following steps
1. Sort the Internal Table
2. Loop the Internal Table
3. Use the Control Break Statement
4. Sum
5. Write Statement
6. Endloop.
Ex.
sort itab.
loop at itab.
at end of kunnr.
sum.
write: 'mara-kunnr'.
endat.
endloop.
Hope the answer of your question.
Regards,
Md Ziauddin.
Edited by: MD ZIAUDDIN on Dec 31, 2008 7:40 PM -
To find sum in an internal table - Bit urgent
Hi SAP experts,
I have an internal table with the following fields and data :
Emp_number Section Days
1 A 10
1 B 20
3 A 20
3 B 10
2 A 20
2 B 10
Now I want to calculate the total days for each employee which is a sum of days of section A and days of section B.
I want the data as below into another internal table
Emp_number Total_days
1 30
2 30
3 30
Could any one tell the code for the same.
Useful answers wud be rewarded.
Vishnu.Hi Vishwanath,
In this case you have to use CONTROL BREAK STATEMENTS.
1.At first
2.At new
3.At end
4.At last
1.At first is going to trigger at the 1st loop of the internal table.From the 2nd loop it is not going to trigger.
It is mainly used for sub headings.
2.At new is going to trigger at the new value of the internal table.
3. At end is going to trigger at the end of the new value of a particular field.
It is mainly use for subtotals.
4.At last is going to trigger at the last loop of the internal table.
It is mainly use for grand totals.
So you gothrough the above 4 statements.
In your case you have to use the third statement i.e., At end.
At end
ur logic
endat.
Maybe you are looking for
-
Linking errors when using ibsta
Hello, I have been trying to write C code to automate a Keithley 2410 through GPIB. I am using Windows XP 32-bit, and VC++. I believe I was successful in getting a handle to the gpib-32.dll. However, I am getting a linking error when I try to use ib
-
Where is the jar and how to use my jar?
when we use a java class, i.e. Applet.class, we need to import it into our code, i know Applet.class is in a jar file under java home directory, but what the jar file's name is and where exactly it is? if i have a classs MyClass.class packaged in pac
-
MMy ipad and iPod and iPhone are now useless. None of my games laoad even after resetting and removing games and then re adding them. What is up with this apple.
-
Change Batch Management Flag in Material Master
TCode : MM17 Select General Material Data MARA Execute(F8) Enter Material Number Execute(F8) Click on Select Fields Icon above New Values under General Material Data tab Choose "Batch Management" Check/Uncheck Flag for Batch Management & Save
-
Hi, Can someone please tell me the commands to stop and start listener? I can't find them anywhere. Thanks,