‎2005 Nov 21 7:52 AM
hi to all,
Please go through the below program...its everything is ok...but i need to add purchase document NET PRICE to this report.
(its actually report based on sales details)
please tell me based on my coding..
TABLES: vbap, vbak.
type-pools: slis. "ALV Declarations
*Data Declaration
*----
-
data : BEGIN OF itabVBAK occurs 0,
VTWEG type vbak-vtweg,
VKORG type vbak-vkorg,
KUNNR type vbak-kunnr,
AUART type vbak-auart,
MATNR type vbap-matnr,
AUDAT type vbap-audat,
NETPR type vbap-netpr,
ARKTX type vbap-arktx,
VBELN type vbap-vbeln,
VRKME type vbap-vrkme,
WAERK type vbap-waerk,
NETWR type vbap-netwr,
end of itabvbak.
*ALV data declarations
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.
**********************SELECTION SCEREEN*******************************
************************************************************************
******************************************BLOCK 2*********************
SELECTION-SCREEN begin of block blk5 with frame title text-004.
********CHECK BOX******
*parameter: P_c2 as checkbox USER-COMMAND CHECK.
*data: cursorfield(20) type c.
*****************************************BLOCK 2 SUB******************
SELECTION-SCREEN begin of block 6 with frame title text-005.
SELECT-OPTIONS:
s_audat for vbap-audat no-extension, "Document Date.
s_kunn1 for vbak-kunnr no-extension ,
"DEFAULT '5525' .
s_matnr for vbap-matnr no-extension.
SELECTION-SCREEN end of block 6.
*****************************************BLOCK 2 SUB******************
SELECTION-SCREEN begin of block 7 with frame title text-006.
SELECT-OPTIONS:
s_auart for vbak-auart no-extension no intervals,
s_vtweg for vbak-vtweg no-extension no intervals ,
s_vkorg for vbak-vkorg no-extension no intervals,
s_netpr for vbap-netpr no-extension no intervals no-display.
SELECTION-SCREEN end of block 7.
SELECTION-SCREEN end of block blk5.
************************************************************************
*********************************************************test********
color management.
DATA : wa_color TYPE lvc_s_scol.
Internal table for color management.
DATA : it_color TYPE TABLE OF lvc_s_scol.
itab for input enabling.
DATA: lt_celltab TYPE lvc_t_styl. "
***********************************************************endtest***
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform build_events.
perform build_print_params.
perform display_alv_report.
*&----
*
*& Form BUILD_FIELDCATALOG
*&----
*
Build Fieldcatalog for ALV Report
*----
*
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-seltext_m = 'Verkaufsbeleg'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-hotspot = 'X'.
fieldcatalog-emphasize = 'C511'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Materialnummer'.
fieldcatalog-col_pos = 1.
fieldcatalog-emphasize = 'C511'.
fieldcatalog-hotspot = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'ARKTX'.
fieldcatalog-seltext_m = 'Bezeichnung'.
fieldcatalog-col_pos = 2.
fieldcatalog-key = ' '.
fieldcatalog-emphasize = 'C110'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Nettopries'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'VRKME'.
fieldcatalog-seltext_m = 'Mengeneinheit'.
fieldcatalog-emphasize = 'C300'. "Column colur, Bold and Inverse off
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'WAERK'.
fieldcatalog-seltext_m = 'Währung'.
fieldcatalog-emphasize = 'C600'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AUDAT'.
fieldcatalog-seltext_m = 'Belegdatum'.
fieldcatalog-col_pos = 6.
fieldcatalog-emphasize = 'C500'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETWR'.
fieldcatalog-seltext_m = 'Nettowert'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-col_pos = 7.
fieldcatalog-emphasize = 'C400'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AUART'.
fieldcatalog-seltext_m = 'Verkaufsbelegart'.
fieldcatalog-col_pos = 8.
fieldcatalog-key = ' '.
fieldcatalog-emphasize = 'C110'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'KUNNR'.
fieldcatalog-seltext_m = 'Kunde'.
fieldcatalog-col_pos = 9.
fieldcatalog-key = 'X'.
fieldcatalog-hotspot = 'X'.
fieldcatalog-emphasize = 'C500'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*&----
*
*& Form BUILD_LAYOUT
*&----
*
Build layout for ALV grid report
*----
*
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-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-info_fieldname = 'LINE_COLOR'.
gd_layout-info_fieldname = 'WS_COLOR'.
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
endform. " BUILD_LAYOUT
*&----
*
*& Form DISPLAY_ALV_REPORT
*&----
*
Display report using ALV grid
*----
*
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'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
it_events = gt_events
is_print = gd_prntparams
i_save = 'X'
is_variant = z_template
tables
t_outtab = itabvbak
exceptions
program_error = 1
others = 2.
CALL FUNCTION REUSE_ALV_COMMENTARY_WRITE
EXPORTING
I_LOGO = 'W3MI'.
*
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
*&----
*
Retrieve data form VBAK table and populate itab it_VBAK
*----
*
form data_retrieval.
data: ld_color(1) type C.
select VBAP~matnr
VBAK~VTWEG
VBAK~VKORG
VBAK~KUNNR
VBAK~AUART
VBAP~AUDAT
VBAP~NETPR
VBAP~ARKTX
VBAP~VRKME
VBAP~WAERK
VBAP~NETWR
VBAP~vbeln
into corresponding fields of table itabvbak from VBAP
inner join VBAK
on VBAPvbeln = VBAKvbeln
where VBAK~kunnr in s_kunn1
and VBAP~AUDAT in s_AUDAT
and VBAP~MATNR in s_MATNR
and VBAK~AUART in s_AUART
and VBAK~VTWEG in s_VTWEG
and VBAK~VKORG in s_VKORG
and VBAP~NETPR in s_NETPR.
endform. " DATA_RETRIEVAL
*----
*
Form TOP-OF-PAGE *
*----
*
ALV Report Header *
*----
*
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
Title
wa_header-typ = 'H'.
wa_header-info = 'Kundenanalyse'.
append wa_header to t_header.
clear wa_header.
Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.
Total No. of Records Selected
describe table itabvbak lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header
i_logo = 'ENJOYSAP_LOGO'.
endform.
*----
*
FORM USER_COMMAND *
*----
*
--> R_UCOMM *
--> RS_SELFIELD *
*----
*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Check function code
CASE r_ucomm.
WHEN '&IC1'.
Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'VBELN'.
Read data table, using index of row user clicked on
READ TABLE itabvbak INTO itabvbak INDEX rs_selfield-tabindex.
with key VBELN = rs_selfield-value
Set parameter ID for transaction screen field
SET PARAMETER ID 'AUN' FIELD itabvbak-vbeln.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
ENDIF.
IF rs_selfield-fieldname = 'MATNR'.
READ TABLE itabvbak INTO itabvbak INDEX rs_selfield-tabindex.
Set parameter ID for transaction screen field
SET PARAMETER ID 'MAT' FIELD itabvbak-matnr.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
*&----
*
*& Form BUILD_EVENTS
*&----
*
Build events table
*----
*
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 1
importing
et_events = gt_events[].
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform. " BUILD_EVENTS
*&----
*
*& Form BUILD_PRINT_PARAMS
*&----
*
Setup print parameters
*----
*
form build_print_params.
gd_prntparams-reserve_lines = '9'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform. " BUILD_PRINT_PARAMS
*&----
*
*& Form END_OF_PAGE
*&----
*
form END_OF_PAGE.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .
endform.
*&----
*
*& Form END_OF_LIST
*&----
*
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip.
write:/40 'Page:', sy-pagno .
endform.
thanks in advance..
‎2005 Nov 21 8:26 AM
By using condition table KONP how can we get the PRICE...can anyone give me a sample code....how to use the condition tables..
raju
‎2005 Nov 21 8:41 AM
hi,
you can connect konp table by using condition record number, vbakKNUMV = KONPKNUMH
regarding purchase document vbak~BSTNK ( Customer purchase order ) number is the field
but i'm not clear with your requirement
cheers,
sasi
‎2005 Nov 21 8:49 AM
my requirement is as i said above...i have a report coded above....i want another field that is PURCHASE DOCUMENT NETPRICE.....
my report is bases on sales details...tables vbak and vbap...so how can i add purchase document net price...
please go through the above coding once..
raju
‎2005 Nov 21 9:11 AM
Hi
try with this.
in itabvbak add two more fields
bstnk like vbak-bstnk,
ebeln like ekpo-vbeln
select VBAP~matnr
VBAK~VTWEG
VBAK~VKORG
VBAK~KUNNR
VBAK~AUART
VBAP~AUDAT
VBAP~NETPR
VBAP~ARKTX
VBAP~VRKME
VBAP~WAERK
VBAP~NETWR
VBAP~vbeln
>> VBAK~BSTNK
into corresponding fields of table itabvbak from VBAP
inner join VBAK
on VBAPvbeln = VBAKvbeln
where VBAK~kunnr in s_kunn1
and VBAP~AUDAT in s_AUDAT
and VBAP~MATNR in s_MATNR
and VBAK~AUART in s_AUART
and VBAK~VTWEG in s_VTWEG
and VBAK~VKORG in s_VKORG
and VBAP~NETPR in s_NETPR.
loop at itabvbak
itabvbak-ebeln = itabvbak-bstnk
modify itabvbak.
endloop
select netpr from ekpo into table xxxxx for all entries in itabvbak where vbeln = itabvbak-vbeln.
‎2005 Nov 21 9:30 AM