ALV Coding for SubTotal
HI
IN ALV'S HOW TO FIND THE SUB TOTAL, CODING TO FIND THE SUBTOTAL.
Edited by: Alvaro Tejada Galindo on Jan 11, 2008 4:09 PM
Hi Jyothsna,
Try the below code.
report zalv10.
type-pools: slis.
data: g_repid like sy-repid,
gs_print type slis_print_alv,
gt_list_top_of_page type slis_t_listheader,
gt_events type slis_t_event,
gt_sort type slis_t_sortinfo_alv,
gs_layout type slis_layout_alv,
gt_fieldcat type slis_t_fieldcat_alv,
fieldcat_ln like line of gt_fieldcat,
col_pos type i.
data: begin of itab,
field1(5) type c,
field2(5) type c,
field3(5) type p decimals 2,
end of itab.
data: begin of itab1 occurs 0.
include structure itab.
data: end of itab1.
data: begin of itab_fieldcat occurs 0.
include structure itab.
data: end of itab_fieldcat.
Print Parameters
parameters:
p_print as checkbox default , PRINT IMMEDIATE
p_nosinf as checkbox default X, NO SELECTION INFO
p_nocove as checkbox default , NO COVER PAGE
p_nonewp as checkbox default , NO NEW PAGE
p_nolinf as checkbox default X, NO PRINT LIST INFO
p_reserv type i. NO OF FOOTER LINE
initialization.
g_repid = sy-repid.
perform print_build using gs_print. Print PARAMETERS
start-of-selection.
TEST DATA
move TEST1 to itab1-field1.
move TEST1 to itab1-field2.
move 10.00 to itab1-field3.
append itab1.
move TEST2 to itab1-field1.
move TEST2 to itab1-field2.
move 20.00 to itab1-field3.
append itab1.
do 50 times.
append itab1.
enddo.
end-of-selection.
perform build.
perform eventtab_build changing gt_events.
perform comment_build changing gt_list_top_of_page.
perform call_alv.
form build.
DATA FIELD CATALOG
Explain Field Description to ALV
data: fieldcat_in type slis_fieldcat_alv.
clear fieldcat_in.
fieldcat_ln-fieldname = FIELD1.
fieldcat_ln-tabname = ITAB1.
*FIELDCAT_LN-NO_OUT = X. FIELD NOT DISPLAY, CHOOSE FROM LAYOUT
fieldcat_ln-key = . *SUBTOTAL* KEY
fieldcat_ln-no_out = .
fieldcat_ln-seltext_l = HEAD1.
append fieldcat_ln to gt_fieldcat.
clear fieldcat_in.
fieldcat_ln-fieldname = FIELD2.
fieldcat_ln-tabname = ITAB1.
fieldcat_ln-no_out = X.
fieldcat_ln-seltext_l = HEAD2.
append fieldcat_ln to gt_fieldcat.
clear fieldcat_in.
fieldcat_ln-fieldname = FIELD3.
fieldcat_ln-tabname = ITAB1.
fieldcat_ln-ref_fieldname = MENGE. <- REF FIELD IN THE DICTIONNARY
fieldcat_ln-ref_tabname = MSEG. <- REF TABLE IN THE DICTIONNARY
fieldcat_ln-no_out = .
fieldcat_ln-do_sum = X. SUM UPON DISPLAY
append fieldcat_ln to gt_fieldcat.
DATA SORTING AND *SUBTOTAL
*data: gs_sort type slis_sortinfo_alv.
clear gs_sort.
gs_sort-fieldname = FIELD1.
gs_sort-spos = 1.
gs_sort-up = X.
gs_sort-subtot = X. ****CRUCIAL STATEMENT*****
append gs_sort to gt_sort.
clear gs_sort.
gs_sort-fieldname = FIELD2.
gs_sort-spos = 2.
gs_sort-up = X.
GS_SORT-SUBTOT = X. ***THIS SHOULD NOT BE UNCOMENTED*
append gs_sort to gt_sort.
endform.
form call_alv.
ABAP List Viewer
call function REUSE_ALV_LIST_DISPLAY
exporting
I_INTERFACE_CHECK =
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
i_callback_program = g_repid
I_CALLBACK_PF_STATUS_SET =
I_CALLBACK_USER_COMMAND =
i_structure_name = ITAB1
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
it_sort = gt_sort[]
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = X
I_SAVE =
IS_VARIANT =
it_events = gt_events[]
IT_EVENT_EXIT =
is_print = gs_print
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = itab1
exceptions
program_error = 1
others = 2.
endform.
HEADER FORM
form eventtab_build changing lt_events type slis_t_event.
constants:
gc_formname_top_of_page type slis_formname value TOP_OF_PAGE.
*GC_FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE END_OF_PAGE.
data: ls_event type slis_alv_event.
call function REUSE_ALV_EVENTS_GET
exporting
i_list_type = 0
importing
et_events = lt_events.
read table lt_events with key name = slis_ev_top_of_page
into ls_event.
if sy-subrc = 0.
move gc_formname_top_of_page to ls_event-form.
append ls_event to lt_events.
endif.
define END_OF_PAGE event
READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE GC_FORMNAME_END_OF_PAGE TO LS_EVENT-FORM.
APPEND LS_EVENT TO LT_EVENTS.
ENDIF.
endform.
form comment_build changing gt_top_of_page type slis_t_listheader.
data: gs_line type slis_listheader.
clear gs_line.
gs_line-typ = H.
gs_line-info = HEADER 1.
append gs_line to gt_top_of_page.
clear gs_line.
gs_line-typ = S.
gs_line-key = STATUS 1.
gs_line-info = INFO 1.
append gs_line to gt_top_of_page.
gs_line-key = STATUS 2.
gs_line-info = INFO 2.
append gs_line to gt_top_of_page.
CLEAR GS_LINE.
GS_LINE-TYP = A.
GS_LINE-INFO = ACTION.
APPEND GS_LINE TO GT_TOP_OF_PAGE.
endform.
form top_of_page.
call function REUSE_ALV_COMMENTARY_WRITE
exporting
it_list_commentary = gt_list_top_of_page.
write: sy-datum, Page No, sy-pagno left-justified.
endform.
form end_of_page.
write at (sy-linsz) sy-pagno centered.
endform.
PRINT SETTINGS
form print_build using ls_print type slis_print_alv.
ls_print-print = p_print. PRINT IMMEDIATE
ls_print-no_print_selinfos = p_nosinf. NO SELECTION INFO
ls_print-no_coverpage = p_nocove. NO COVER PAGE
ls_print-no_new_page = p_nonewp.
ls_print-no_print_listinfos = p_nolinf. NO PRINT LIST INFO
ls_print-reserve_lines = p_reserv.
endform.
<REMOVED BY MODERATOR>
Thankyou,
Regards.
Edited by: Alvaro Tejada Galindo on Jan 11, 2008 4:10 PM
Similar Messages
-
Is there any functionality for AVERAGE in ALV, like do_sum, subtot?
Hi Experts,
In my_alv report, am doing sub/totals for prices, by using do_sum, subtot functions.........fine. But, I need to do/display the AVERAGE value for Discount % column?
Is there any functionality for AVERAGE in ALV, like do_sum, subtot?
thanqhi
check these links out
http://www.sapfans.com/forums/viewtopic.php?t=20386
http://www.sapfans.com/forums/viewtopic.php?t=85191
http://www.sapfans.com/forums/viewtopic.php?t=88401
http://www.sapfans.com/forums/viewtopic.php?t=17335
regards
vijay
reward points if helpful -
Alv Report for invoice details
Dear All,
I need to develop one alv report for following details. i developed coding for this requirment but i am getting some error.kindley help me to how to move data from different internal table to final internal table. I used LOOP AT and READ Statement even i didn't get any output.
kindley help me out.
TYPES: BEGIN OF XT_TAB,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
STCD1 LIKE LFA1-STCD1,
STCD2 LIKE LFA1-STCD2,
STCD3 LIKE LFA1-STCD3,
STCD4 LIKE LFA1-STCD4,
END OF XT_TAB.
TYPES: BEGIN OF YT_TAB,
BUKRS LIKE BSEG-BUKRS,
BELNR LIKE BSEG-BELNR,
BUZEI LIKE BSEG-BUZEI,
LIFNR LIKE BSEG-LIFNR,
GJAHR LIKE BSEG-GJAHR,
END OF YT_TAB.
TYPES: BEGIN OF ZT_TAB,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
STCD2 LIKE LFA1-STCD2,
BELNR LIKE BSEG-BELNR,
BUZEI LIKE BSEG-BUZEI,
GJAHR LIKE BSEG-GJAHR,
END OF ZT_TAB.
I N T E R N A L T A B L E D E C L A R A T I O N S *
*-----Internal table to store data
DATA: ITAB1 TYPE STANDARD TABLE OF XT_TAB INITIAL SIZE 0,
WA_TAB1 TYPE XT_TAB.
DATA: ITAB2 TYPE STANDARD TABLE OF YT_TAB INITIAL SIZE 0,
WA_TAB2 TYPE YT_TAB.
DATA: ITAB TYPE STANDARD TABLE OF ZT_TAB WITH HEADER LINE,
WA_ITAB TYPE ZT_TAB,
ITAB_FINAL2 TYPE STANDARD TABLE OF ZT_TAB.
DATA: ITAB_TEMP1 TYPE STANDARD TABLE OF ZT_TAB WITH HEADER LINE.
Selection Screen Declarations *
SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN begin OF LINE.
SELECTION-SCREEN COMMENT (23) text-003 FOR FIELD P_LIFNR.
PARAMETERS P_LIFNR LIKE LFA1-LIFNR OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK bk1.
START-OF-SELECTION.
PERFORM XTRACT_DATA.
END-OF-SELECTION.
*-----Filling the Output table
PERFORM populate_main_table.
PERFORM BUILD_FIELDCATALOG.
PERFORM SORTING.
PERFORM BUILD_LAYOUT.
PERFORM BUILD_ALV_GRID_DISPLAY.
Form XTRACT_DATA
FORM XTRACT_DATA .
*SELECT
a~LIFNR
a~NAME1
a~STCD2
b~BELNR
b~BUZEI
b~GJAHR
INTO TABLE ITAB
FROM LFA1 as a INNER JOIN BSEG as b
ON aLIFNR = bLIFNR
WHERE a~LIFNR = P_LIFNR.
SELECT LIFNR
NAME1
STCD1
STCD2
STCD3
STCD4
FROM LFA1
INTO TABLE ITAB1
WHERE LIFNR = P_LIFNR.
IF NOT ITAB1[] IS INITIAL.
SORT ITAB1 BY LIFNR.
SELECT BELNR
BUZEI
LIFNR
GJAHR
INTO TABLE ITAB2
FROM BSEG
FOR ALL ENTRIES IN ITAB1
WHERE LIFNR = ITAB1-LIFNR.
ENDIF.
ENDFORM. " XTRACT_DATA
*& Form POPULATE_MAIN_TABLE
text
--> p1 text
<-- p2 text
FORM POPULATE_MAIN_TABLE .
LOOP AT ITAB1 INTO WA_TAB1.
ITAB-LIFNR = ITAB1-LIFNR.
ITAB-NAME1 = ITAB1-NAME1.
ITAB-STCD2 = ITAB1-STCD2.
READ TABLE ITAB2 INTO WA_TAB2 WITH KEY LIFNR = WA_TAB1-LIFNR.
IF sy-subrc = 0.
ITAB-BELNR = ITAB1-BELNR.
ITAB-BUZEI = ITAB1-BUZEI.
ITAB-GJAHR = ITAB1-GJAHR.
ENDIF.
ENDLOOP.
ENDFORM. " POPULATE_MAIN_TABLE
Form BUILD_FIELDCATALOG
FORM BUILD_FIELDCATALOG .
REFRESH t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 1.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Vendor Number'.
wa_fcat-seltext_m = 'Vendor Number'.
wa_fcat-seltext_l = 'Vendor Number'.
wa_fcat-fieldname = 'LIFNR'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 2.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Vendor Name'.
wa_fcat-seltext_m = 'Vendor Name'.
wa_fcat-seltext_l = 'Vendor Name'.
wa_fcat-fieldname = 'NAME1'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 3.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Vendor TIN Number'.
wa_fcat-seltext_m = 'Vendor TIN Number'.
wa_fcat-seltext_l = 'Vendor TIN Number'.
wa_fcat-fieldname = 'STCD2'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 4.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Document No'.
wa_fcat-seltext_m = 'Document No'.
wa_fcat-seltext_l = 'Document No'.
wa_fcat-fieldname = 'BELNR'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 5.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Item Number'.
wa_fcat-seltext_m = 'Item Number'.
wa_fcat-seltext_l = 'Item Number'.
wa_fcat-fieldname = 'BUZEI'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 6.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Fiscal Year'.
wa_fcat-seltext_m = 'Fiscal Year'.
wa_fcat-seltext_l = 'Fiscal Year'.
wa_fcat-fieldname = 'GJAHR'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
ENDFORM. " BUILD_FIELDCATALOG
Form BUILD_LAYOUT
FORM BUILD_LAYOUT .
GD_LAYOUT-NO_INPUT = 'X'.
GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GD_LAYOUT-TOTALS_TEXT = 'TOTALS'.
ENDFORM. " BUILD_LAYOUT
Form BUILD_ALV_GRID_DISPLAY
FORM BUILD_ALV_GRID_DISPLAY .
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 = t_fcat[]
it_events = gt_events
is_print = gd_prntparams
it_sort = it_sortcat[]
i_save = 'X'
TABLES
t_outtab = ITAB
EXCEPTIONS
program_error = 1
OTHERS = 2.
thanks and regards
MurugeshTYPES: BEGIN OF XT_TAB,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
STCD1 LIKE LFA1-STCD1,
STCD2 LIKE LFA1-STCD2,
STCD3 LIKE LFA1-STCD3,
STCD4 LIKE LFA1-STCD4,
END OF XT_TAB.
TYPES: BEGIN OF YT_TAB,
BUKRS LIKE BSEG-BUKRS,
BELNR LIKE BSEG-BELNR,
BUZEI LIKE BSEG-BUZEI,
LIFNR LIKE BSEG-LIFNR,
GJAHR LIKE BSEG-GJAHR,
END OF YT_TAB.
TYPES: BEGIN OF ZT_TAB,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
STCD2 LIKE LFA1-STCD2,
BELNR LIKE BSEG-BELNR,
BUZEI LIKE BSEG-BUZEI,
GJAHR LIKE BSEG-GJAHR,
END OF ZT_TAB.
I N T E R N A L T A B L E D E C L A R A T I O N S *
*-----Internal table to store data
DATA: ITAB1 TYPE STANDARD TABLE OF XT_TAB INITIAL SIZE 0,
WA_TAB1 TYPE XT_TAB.
DATA: ITAB2 TYPE STANDARD TABLE OF YT_TAB INITIAL SIZE 0,
WA_TAB2 TYPE YT_TAB.
DATA: ITAB TYPE STANDARD TABLE OF ZT_TAB WITH HEADER LINE,
WA_ITAB TYPE ZT_TAB,
ITAB_FINAL2 TYPE STANDARD TABLE OF ZT_TAB.
DATA: ITAB_TEMP1 TYPE STANDARD TABLE OF ZT_TAB WITH HEADER LINE.
Selection Screen Declarations *
SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN begin OF LINE.
SELECTION-SCREEN COMMENT (23) text-003 FOR FIELD P_LIFNR.
PARAMETERS P_LIFNR LIKE LFA1-LIFNR OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK bk1.
START-OF-SELECTION.
PERFORM XTRACT_DATA.
END-OF-SELECTION.
*-----Filling the Output table
PERFORM populate_main_table.
PERFORM BUILD_FIELDCATALOG.
PERFORM SORTING.
PERFORM BUILD_LAYOUT.
PERFORM BUILD_ALV_GRID_DISPLAY.
Form XTRACT_DATA
FORM XTRACT_DATA .
*SELECT
a~LIFNR
a~NAME1
a~STCD2
b~BELNR
b~BUZEI
b~GJAHR
INTO TABLE ITAB
FROM LFA1 as a INNER JOIN BSEG as b
ON aLIFNR = bLIFNR
WHERE a~LIFNR = P_LIFNR.
SELECT LIFNR
NAME1
STCD1
STCD2
STCD3
STCD4
FROM LFA1
INTO TABLE ITAB1
WHERE LIFNR = P_LIFNR.
IF NOT ITAB1[] IS INITIAL.
SORT ITAB1 BY LIFNR.
SELECT BELNR
BUZEI
LIFNR
GJAHR
INTO TABLE ITAB2
FROM BSEG
FOR ALL ENTRIES IN ITAB1
WHERE LIFNR = itab1-lifnr.
ENDIF.
ENDFORM. " XTRACT_DATA
*& Form POPULATE_MAIN_TABLE
text
--> p1 text
<-- p2 text
FORM POPULATE_MAIN_TABLE .
LOOP AT ITAB1 INTO WA_TAB1.
ITAB-LIFNR = ITAB1-LIFNR.
ITAB-NAME1 = ITAB1-NAME1.
ITAB-STCD2 = ITAB1-STCD2.
READ TABLE ITAB2 INTO WA_TAB2 WITH KEY LIFNR = WA_TAB1-LIFNR.
IF sy-subrc = 0.
ITAB-BELNR = ITAB1-BELNR.
ITAB-BUZEI = ITAB1-BUZEI.
ITAB-GJAHR = ITAB1-GJAHR.
ENDIF.
ENDLOOP.
LOOP AT itab1 INTO wa_tab1.
MOVE: wa_tab1-lifnr TO itab-lifnr,
wa_tab1-name1 TO itab-name1,
wa_tab1-stcd2 TO itab-stcd2.
Append itab.
READ TABLE itab2 TRANSPORTING NO FIELDS WITH KEY lifnr = wa_tab1-lifnr.
IF sy-subrc eq 0.
MOVE: wa_tab2-lifnr TO itab-lifnr,
wa_tab2-belnr TO itab-belnr,
wa_tab2-buzei TO itab-buzei,
wa_tab2-gjahr TO itab-gjahr.
Append itab.
endif.
endloop.
*LOOP AT t_agr_tcodes INTO s_agr_tcodes.
READ TABLE t_tstc
TRANSPORTING NO FIELDS
WITH KEY tcode = s_agr_tcodes-tcode.
IF sy-subrc eq 0.
MOVE: s_agr_tcodes-tcode TO it_agr_tcodes-tcode,
s_agr_tcodes-agr_name to it_agr_tcodes-agr_name,
t_tstc-pgmna to it_agr_pgmna.
*Append it_agr_tcodes.
*endif.
*endloop.
ENDFORM. " POPULATE_MAIN_TABLE
Form BUILD_FIELDCATALOG
FORM BUILD_FIELDCATALOG .
REFRESH t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 1.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Vendor Number'.
wa_fcat-seltext_m = 'Vendor Number'.
wa_fcat-seltext_l = 'Vendor Number'.
wa_fcat-fieldname = 'LIFNR'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 2.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Vendor Name'.
wa_fcat-seltext_m = 'Vendor Name'.
wa_fcat-seltext_l = 'Vendor Name'.
wa_fcat-fieldname = 'NAME1'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 3.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Vendor TIN Number'.
wa_fcat-seltext_m = 'Vendor TIN Number'.
wa_fcat-seltext_l = 'Vendor TIN Number'.
wa_fcat-fieldname = 'STCD2'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 4.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Document No'.
wa_fcat-seltext_m = 'Document No'.
wa_fcat-seltext_l = 'Document No'.
wa_fcat-fieldname = 'BELNR'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 5.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Item Number'.
wa_fcat-seltext_m = 'Item Number'.
wa_fcat-seltext_l = 'Item Number'.
wa_fcat-fieldname = 'BUZEI'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 6.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Fiscal Year'.
wa_fcat-seltext_m = 'Fiscal Year'.
wa_fcat-seltext_l = 'Fiscal Year'.
wa_fcat-fieldname = 'GJAHR'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
ENDFORM. " BUILD_FIELDCATALOG
Form BUILD_LAYOUT
FORM BUILD_LAYOUT .
GD_LAYOUT-NO_INPUT = 'X'.
GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GD_LAYOUT-TOTALS_TEXT = 'TOTALS'.
ENDFORM. " BUILD_LAYOUT
Form BUILD_ALV_GRID_DISPLAY
FORM BUILD_ALV_GRID_DISPLAY .
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 = t_fcat[]
it_events = gt_events
is_print = gd_prntparams
it_sort = it_sortcat[]
i_save = 'X'
TABLES
t_outtab = ITAB
EXCEPTIONS
program_error = 1
OTHERS = 2.
Edited by: Murugesh P on Apr 6, 2009 10:54 AM
Edited by: Murugesh P on Apr 6, 2009 10:54 AM -
ALV REPORT FOR TOP 10 CUSTOMERS
hI,
sap guys
I need a help on alv. iam getting alv report. now i need to get TOP 10 customers in my report.
My report having selling price , cost price , GP , GP% .
Final internal table iam sorting based on Selling price. But how to Get the Top 10 customers in my report.
Plz help me..hi
good day brother
Before youve given the solution for top 20 cust as well as subtot.. iam getting a prob for one branch for subtot.
Plz see the code..
Ive dev the smart form for top 20 customers by Branch wise.. I have 17 branches in final itab.
Every thing is fine except one branch for the Subtot.
For getting Subtot as well as Getting the top 20 cust.. the below code ive used.
First branch like lt_br_out2 got 503 records
lt_br_out3 == 213
lt_br_out4 == 0
lt_br_out5== 82
lt_br_out6 ==89
lt_br_out7 ==118
lt_br_out8 == 45
lt_br_out9 == 64
lt_br_out10 == 53
lt_br_out11 == 47
lt_br_out12 == 56
lt_br_out13 == 20 *************** "Problem with this internal table.
lt_br_out14 ==170
Problem: All Branches are getting subtotal and top 20 cust except " LT_BR_OUT13"...Before its going to cal the top 20 cust. its has only 20 records.
Actually iam counting the top 20 cust as well as cal subtot and passing to Final Internal Table..
SORT lt_br_out13 BY p1_a_p DESCENDING.
CLEAR : lwa_out6.
LOOP AT lt_br_out13 INTO lwa_out6.
IF sy-tabix > 20.
CLEAR: lwa_out6.
***adding the subtot
lwa_out6-ort01 = lv_text.
lwa_out6-p1_a_p = lv_brtot.
lwa_out6-p2_a_p = lv_brtot1.
lwa_out6-act_gross_p = lv_br.
lwa_out6-act_gross_perc1 = lv_brperc1.
APPEND lwa_out6 TO lt_br_final.
EXIT.
ELSE.
***calc the sub tot
lv_text = 'Sub Total'.
lv_brtot = lv_brtot + lwa_out6-p1_a_p. " selling price
lv_brtot1 = lv_brtot1 + lwa_out6-p2_a_p. " Cost price
lv_br = lv_brtot - lv_brtot1.
lv_brperc = ( lv_br / lv_brtot ) * 100.
IF lv_brperc NE 0.
WRITE lv_brperc TO lv_brperc1 LEFT-JUSTIFIED.
CONCATENATE lv_brperc1 '%' INTO lv_brperc1 SEPARATED BY space.
ENDIF.
APPEND lwa_out6 TO lt_br_final.
ENDIF.
ENDLOOP.
If i put sy-tabix >= 20, thne iam getting subtotal but iam getting only 19 records.
Could u plz advice me.. Ive solved yesterday problem
Regards -
How to set/get the values thru Wedbynpro coding for User mapping fields
Hi All
In system object we have the user mapping fields like District,city,plant,Salesmanager.
now we want to set/get the values of these usermapping fields of system object thru webdynpro coding...
if anybody have sample codes of the same then it would be great help to me
Thanks in advance
Thanks
Trisha RaniHi Kavitha
Thanks for your reply
My requirement is exactly as follows.
1) i have created one portal system object in system administration and also i created usermapping fields in the system object from the usermanagement in system object.
i created the user mapping fields like Plant,SalesManager,District etc.
i also created the system alias name for the same system object
2) Now i came to persoanlize link and mapped the system object to the portal user.
while mapping to the system object we need to enter Mapping userId, Password , once we enter these values and we can also enter the values of usermapping fields which we defined while creating the system object ( for example District,Salesmanager,Plant etc)
once we enter all the values and click on save then these usermapping values to be mapped to the portal user.
3) Now my requirement is , i want to control the usermapping field values thru webdynpro coding for setting/getting the values.
I need sample code of the same.
Please let me know if u need more details on the same.
Thanks
Trisha Rani -
Devolped an ALV report for daily cash receipts for selected date range
hi,
how to devlop an ALV report for daily cash receipts for selected date range.for this report what are the tables and fields we have to use.what is the selectionscreen&what is logic.give me sample report.hi,
how to devlop an ALV report for daily cash receipts for selected date range.for this report what are the tables and fields we have to use.what is the selectionscreen&what is logic.give me sample report. -
Devloped an ALV report for daily cash receipts for selected date range
hi,
how to devlop an ALV report for daily cash receipts for selected date range.for this report what are the tables and fields we have to use.what is the selectionscreen&what is logic.give me sample report.Hi,
You can develop simple reports using Report Painter.
You may be also interested in:
Check report SAPMF05A for credit memo
See the following Std reports on Payment Advices execute the Tcodes:
S_ALR_87009888
S_ALR_87009889
S_ALR_87009890
S_ALR_87009891
S_ALR_87009892
S_ALR_87009893
S_ALR_87009978
S_ALR_87009979
S_ALR_87009980
S_ALR_87009981
S_ALR_87009982
S_ALR_87009983
S_ALR_87010056
S_ALR_87010057
S_ALR_87010058
S_ALR_87010059
S_ALR_87010060
S_ALR_87010061
S_ALR_87010066
S_ALR_87010067
S_ALR_87012106
S_ALR_87012107
S_ALR_87012108
S_ALR_87012109
S_ALR_87012110
S_ALR_87012111
S_ALR_87012116
S_ALR_87012117
S_ALR_87012200
S_ALR_87012201
S_ALR_87012202
S_ALR_870122
S_ALR_87012204
S_ALR_87012205
S_ALR_87012350
S_ALR_87012351
S_ALR_87012352
S_ALR_87012353
S_ALR_87012354
S_ALR_87012355
sample ALV report:
tables:
marav. "Table MARA and table MAKT
Data to be displayed in ALV
Using the following syntax, REUSE_ALV_FIELDCATALOG_MERGE can auto-
matically determine the fieldstructure from this source program
Data:
begin of imat occurs 100,
matnr like marav-matnr, "Material number
maktx like marav-maktx, "Material short text
matkl like marav-matkl, "Material group (so you can test to make
" intermediate sums)
ntgew like marav-ntgew, "Net weight, numeric field (so you can test to
"make sums)
gewei like marav-gewei, "weight unit (just to be complete)
end of imat.
Other data needed
field to store report name
data i_repid like sy-repid.
field to check table length
data i_lines like sy-tabix.
Data for ALV display
TYPE-POOLS: SLIS.
data int_fcat type SLIS_T_FIELDCAT_ALV.
select-options:
s_matnr for marav-matnr matchcode object MAT1.
start-of-selection.
read data into table imat
select * from marav
into corresponding fields of table imat
where
matnr in s_matnr.
end-of-selection.
Now, we start with ALV
To use ALV, we need a DDIC-structure or a thing called Fieldcatalogue.
The fieldcatalouge can be generated by FUNCTION
'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any
report source, including this report.
The only problem one might have is that the report and table names
need to be in capital letters. (I had it )
Store report name
i_repid = sy-repid.
Create Fieldcatalogue from internal table
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = sy-repid
I_INTERNAL_TABNAME = 'IMAT' "capital letters!
I_INCLNAME = sy-repid
CHANGING
CT_FIELDCAT = int_fcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = i_repid
I_STRUCTURE_NAME = 'marav'
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = imat.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC .
ENDIF.
Hope this will help.
Regards,
Naveen. -
Coding for ABAP Proxy and mapping
Hi XI Ds
which one need coding neither ABAP Proxy nor ABAP Mapping
ThanksHi Kushee ,
We need coding for both ABAP Proxy and mapping. We need to know some OO(Object Oreinted) ABAP concepts.
We can also import JAVA CODE for certain functionality.
Check the following websites for clarity:
how to create a flat file out of an IDoc-XML by means of an ABAP mapping program and the J2EE File Adapter.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/46759682-0401-0010-1791-bd1972bc0b8a
cheers!
gyanaraj -
Coding for static fill-out form
fill out form questionnaire?
I am creating in Flash CS4 (AS3) a static fill out form for a website that I am involved in. The questionnaire helps to determine whether a person is suseptible to drug and alcohol abuse with either a postive answer (not likely to develop substance abuse) or a negative answer (likely to develop substance abuse)
There are six questions on this form that MUST be answered either yes or no.
I have created the form with all art and buttons and it is ready to implement in Dreamweaver but need the scripting to make work.
The six YES buttons are assigned instance names of cb1, cb3, cb5, cb7, cb9 and cb11
The six NO buttons are assigned instance names of cb2, cb4, cb6, cb8, cb10
and cb12.
When the participant answers all six questions either yes or no they will hit a Submit button (with an instance name of submit) that will direct them to a new web/flash page with appropriate answer.
If the participant answers TWO or more questions with YES and hit submit they will be directed to a new page/doc in the website with the negative answer.
If the participant answers ONE YES and hit submit they will be directed to a new page/doc in the website with a positive answer.
If the participant answers ALL NO and hit submit they will be directed to a new page/doc in the website with the same positive answer as answering with ONE YES response.
I assume this is a very complex coding problem. I am a beginner/intermidiate flash person with extreme novice understanding of coding. I know what stop(); does in AS3 and understand simple clickTag coding etc.
Would appreciate any help with AS3 coding for this document.
I usually find coding on forums like these and online blogs - but I don't even know where to begin looking.
Thankson the timeline that contains your buttons:
var yesNum:int=0;
var noNum:int=0;
submit_btn.addEventListener(MouseEvent.CLICK,submitF);
for(var i:int=1;i<=12;i++){
if(1%2==0){
this["cb"+i].addEventListener(MouseEvent.CLICK,noF);
} else {
this["cb"+i].addEventListener(MouseEvent.CLICK,yesF);
function yesF(e:MouseEvent):void{
yesNum++;
e.currentTarget.removeEventListener(MouseEvent.CLICK,yesF);
function yesF(e:MouseEvent):void{
noNum++;
e.currentTarget.removeEventListener(MouseEvent.CLICK,noF);
function submitF(e:MouseEvent):void{
if(yesNum+noNum==12){
// take appropriate action based on yesNum and/or noNum
} else {
// error. all questions not answered. -
ALV report for Purchase Requisitions(PR)
Hai All!
i am developing an ALV report for Purchase Requisitions(PR) tht are not approved ( ie IN RELEASE status), so i want to get who has approved PR and who has not approved it... from which table & which field i can get this data...
plz help meHi Following fields are used to set / reset release of PR
EBAN-FRGKZ
EBAN-FRGZU
EBAN-FRGST.
You will have to understand combination of these field from MM Fuctional Consultant.
rgds
rajesh
Edited by: RAJESH KUMAR on Aug 6, 2008 12:18 PM -
Require coding for purchase requisation outstanding aging report
Hi Gurus,
I got a requirment to develop purchase requisation outstanding aging report.Please provide me the coding for purchase requisation outstanding aging report.
Points will be rewarded for every reply.
Regards ,
Sonali.Hi Sonali,
You need to use EBAN, EBKN Tables.
Regards,
Satish -
Hi All,
Is there a way to make customized reports using ALV grid for Inventory reporting as like in Purchasing.
Regards
AshokI think you need to have those developed.
See threads below.
http://scn.sap.com/thread/321656
http://wiki.sdn.sap.com/wiki/display/Snippets/MM+Inventory+Report+ALV+GRID -
Hi all,
using this ZUS_SDN_THREE_ALV_GRIDS program structure i have generated the all the fields from table.
could you please guide me how to generate the ALV report for splecific fileds from individual tables.
if i click in click on grid1 (that is sales header details) we need populate the item details in grid2 and paralally customer details in grid3.
please guide me how to resolve the issuee..
thanks in advance
Srinivas...Hi,
I have done an example, like on 1st grid it displays header data (EKKO) and when you double click on any record, for that PO you will get item details (EKPO) on 2nd grid,
In the similar way, you can add one more grid and populate it with your own data simultaneously along with 2nd grid.
*& Report ZOOABAP1_SOW
report zabap2.
* TABLES
tables:ekko.
* DATA DECLARATIONS
data: grid1 type ref to cl_gui_alv_grid,
grid2 type ref to cl_gui_alv_grid,
container1 type ref to cl_gui_custom_container,
container2 type ref to cl_gui_custom_container,
flag.
* INTERNAL TABLES
data: it_ekko type table of ekko.
data: wa_ekko like line of it_ekko.
data: it_ekpo type table of ekpo.
data: it_fcat1 type lvc_t_fcat,
wa_fcat1 type lvc_s_fcat,
it_fcat2 type lvc_t_fcat,
wa_fcat2 type lvc_s_fcat,
wa_layout1 type lvc_s_layo,
wa_layout2 type lvc_s_layo,
wa_variant type disvariant.
* SELECTION-SCREEN
selection-screen begin of block b with frame title text-s01.
select-options: s_ebeln for ekko-ebeln.
selection-screen end of block b.
* CLASS lcl1 DEFINITION
class lcl1 definition.
public section.
methods:
handler_dbl_clk for event double_click
of cl_gui_alv_grid
importing e_row.
endclass. "lcl1 DEFINITION
* CLASS lcl1 IMPLEMENTATION
class lcl1 implementation.
method handler_dbl_clk.
read table it_ekko into wa_ekko index e_row-index.
if sy-subrc = 0.
perform get_ekpo.
endif.
endmethod. "handler_dbl_clk
endclass. "lcl1 IMPLEMENTATION
* START_OF_SELECTION
start-of-selection.
* Get PO header data
perform get_ekko.
* screen for container
call screen 100.
*& Module STATUS_0100 OUTPUT
* text
module status_0100 output.
set pf-status 'PFS'.
set titlebar 'TIT'.
data: obj type ref to lcl1.
if flag is initial.
create object container1
exporting
container_name = 'CONT1'.
create object container2
exporting
container_name = 'CONT2'.
create object grid1
exporting
i_parent = container1.
create object grid2
exporting
i_parent = container2.
create object obj.
set handler obj->handler_dbl_clk for grid1.
perform build_fcat.
perform build_layout.
call method grid1->set_table_for_first_display
exporting
* i_buffer_active =
* i_bypassing_buffer =
* i_consistency_check =
* i_structure_name = 'EKKO'
* is_variant = wa_variant
i_save = 'X'
* i_default = 'X'
is_layout = wa_layout1
* is_print =
* it_special_groups =
* it_toolbar_excluding =
* it_hyperlink =
* it_alv_graphics =
* it_except_qinfo =
* ir_salv_adapter =
changing
it_outtab = it_ekko
it_fieldcatalog = it_fcat1
* it_sort =
* it_filter =
* EXCEPTIONS
* invalid_parameter_combination = 1
* program_error = 2
* too_many_lines = 3
* others = 4
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
flag = 'X'.
endif.
endmodule. " STATUS_0100 OUTPUT
*& Form get_ekko
* text
* --> p1 text
* <-- p2 text
form get_ekko .
select ebeln bsart lifnr
from ekko
into corresponding fields of table it_ekko
where ebeln in s_ebeln.
endform. " get_ekko
*& Form GET_EKPO
* text
* --> p1 text
* <-- p2 text
form get_ekpo .
select ebeln ebelp menge meins peinh from ekpo
into corresponding fields of table it_ekpo
where ebeln = wa_ekko-ebeln.
if not it_ekpo[] is initial.
call method grid2->set_table_for_first_display
exporting
* i_buffer_active =
* i_bypassing_buffer =
* i_consistency_check =
* i_structure_name =
* is_variant =
* i_save =
* i_default = 'X'
is_layout = wa_layout2
* is_print =
* it_special_groups =
* it_toolbar_excluding =
* it_hyperlink =
* it_alv_graphics =
* it_except_qinfo =
* ir_salv_adapter =
changing
it_outtab = it_ekpo
it_fieldcatalog = it_fcat2
* it_sort =
* it_filter =
* EXCEPTIONS
* invalid_parameter_combination = 1
* program_error = 2
* too_many_lines = 3
* others = 4
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endif.
endform. " GET_EKPO
*& Module USER_COMMAND_0100 INPUT
* text
module user_command_0100 input.
case sy-ucomm.
when 'BACK' or 'EXIT' or 'CANC'.
call method container1->free.
call method container2->free.
leave to screen 0.
endcase.
endmodule. " USER_COMMAND_0100 INPUT
*& Form build_fcat
* text
* --> p1 text
* <-- p2 text
form build_fcat .
* fieldcatalog for EKKO table
wa_fcat1-col_pos = '1'.
wa_fcat1-fieldname = 'EBELN'.
wa_fcat1-tabname = 'EKKO'.
wa_fcat1-coltext = 'PO No.'.
append wa_fcat1 to it_fcat1.
clear wa_fcat1.
wa_fcat1-col_pos = '2'.
wa_fcat1-fieldname = 'BSART'.
wa_fcat1-tabname = 'EKKO'.
wa_fcat1-coltext = 'PO Type'.
append wa_fcat1 to it_fcat1.
clear wa_fcat1.
wa_fcat1-col_pos = '3'.
wa_fcat1-fieldname = 'LIFNR'.
wa_fcat1-tabname = 'EKKO'.
wa_fcat1-coltext = 'Vendor No.'.
append wa_fcat1 to it_fcat1.
clear wa_fcat1.
* fieldcatalog for EKPO table
wa_fcat2-col_pos = '1'.
wa_fcat2-fieldname = 'EBELN'.
wa_fcat2-tabname = 'EKPO'.
wa_fcat2-coltext = 'PO No.'.
append wa_fcat2 to it_fcat2.
clear wa_fcat2.
wa_fcat2-col_pos = '2'.
wa_fcat2-fieldname = 'EBELP'.
wa_fcat2-tabname = 'EKPO'.
wa_fcat2-coltext = 'PO Item'.
append wa_fcat2 to it_fcat2.
clear wa_fcat2.
wa_fcat2-col_pos = '3'.
wa_fcat2-fieldname = 'MENGE'.
wa_fcat2-tabname = 'EKPO'.
wa_fcat2-coltext = 'Quantity'.
append wa_fcat2 to it_fcat2.
clear wa_fcat2.
wa_fcat2-col_pos = '4'.
wa_fcat2-fieldname = 'MEINS'.
wa_fcat2-tabname = 'EKPO'.
wa_fcat2-coltext = 'UOM'.
append wa_fcat2 to it_fcat2.
clear wa_fcat2.
wa_fcat2-col_pos = '5'.
wa_fcat2-fieldname = 'PEINH'.
wa_fcat2-tabname = 'EKPO'.
wa_fcat2-coltext = 'Price Unit'.
append wa_fcat2 to it_fcat2.
clear wa_fcat2.
endform. " build_fcat
*& Form build_layout
* text
* --> p1 text
* <-- p2 text
form build_layout .
clear wa_layout1.
wa_layout1-grid_title = 'Header data'.
* wa_layout-sel_mode = 'A'. "allow to select multiple lines
clear wa_layout2.
wa_layout2-grid_title = 'Item Data'.
endform. " build_layout
If you have any poblems while doing this, post it.
Do reward points for all helpful answers
Regards,
Sowjanya -
Alv report for multiple record insertion
hi,
i'm new to abap. i'm using alv report for record display and insertion. how can i insert multiple records from alv to my table??well that can be achieved only by running BDC inside alv report to enter the entries.and in that too you can append or edit single entries only
reward if useful
regards
vivek -
Please tell me if coding for ITS is done in ABAP.
Hi all,
Please tell me if coding for ITS based on ABAP.
Thanks.Hello Sanjiv,
I'm not sure I understand the question...
ITS uses BusinessHTML and HTML and other Internet standards (css, js, etc). However, you can develop in ABAP and then use SE80 to generate a template for you or use the WEBGUI service to call your ABAP developed transaction directly. You can find more information by using the links at the top of the ITS forum to go to the Wiki or FAQ or Product page for the ITS.
Edgar
Maybe you are looking for
-
Searching a string in a column
Hi All, I have a table having a column containing names,i need to write a query that would fetch the exact string from the table. eg. Available funcions- is the data in the table Query: select name from <table> where LOWER(name) like LOWER('av%') the
-
Hr_ex_employee_api
Hi All, I need to use the hr_ex_employee_api.actual_termination_emp and hr_ex_employee_api.update_term_details_emp to terminate the employee I just need to know that what should be passed to the parameters in both API's and which table am I supposed
-
Jsp 2.0 Expression Language Performance
Hi, We're using EL throughout our application JSPs and Tags (${x} expressions), and we've discovered that for each dynamic expression used, the weblogic implementation creates a new ExpressionEvaluator object, a new Parser object, performs
-
Hi! i'm facing problem about full screen option. i have a layout where have four container. From those i want to make full screen one of them which i indicated in image. Would you help me in this regards with tutorials or source code help.
-
Hello all, I am trying to set up distributed Hotlog Change Data Capture (CDC) with both source and staging databases on 10.2.0.3. I have managed to set up everything alright until I try to great my first change table on the staging database. We tried