Posted: Sat Sep 29, 2007 2:33 pm Post subject: Sales Order ALV report
Code:
TYPE-POOLS
type-pools : slis.
* Tables
tables : VBAK,
VBAP.
* Internal table for VBAK Table
data : begin of i_vbak occurs 0,
vbeln like vbak-vbeln,
bstnk like vbak-bstnk,
vdatu like vbak-vdatu,
end of i_vbak.
* Internal table for VBAP and MATNR
data : begin of i_vbap occurs 0,
vbeln like vbap-vbeln,
matnr like vbap-matnr,
kdmat like vbap-kdmat,
kwmeng like vbap-kwmeng,
netpr like vbap-netpr,
maktx like makt-maktx,
end of i_vbap.
* Internal tables
data : begin of i_sales occurs 0,
vdatu like vbak-vdatu,
bstnk like vbak-bstnk,
matnr like vbap-matnr,
maktx like makt-maktx,
kdmat like vbap-kdmat,
kwmeng like vbap-kwmeng,
netpr like vbap-netpr,
end of i_sales.
* Variable for ALV
data : v_repid like sy-repid,
gt_fieldcat type slis_t_fieldcat_alv.
* Selection-screen
selection-screen : begin of block blk with frame title text-001.
select-options : s_vbeln for vbak-vbeln,
s_erdat for vbak-erdat,
s_ernam for vbak-ernam,
s_vdatu for vbak-vdatu obligatory,
s_BSTNK for vbak-BSTNK,
s_KUNNR for vbak-kunnr,
s_matnr for vbap-matnr,
s_KDMAT for vbap-KDMAT.
selection-screen : end of block blk.
* Initilization
initialization.
v_repid = sy-repid.
************************************************************************
*************** S T A R T - O F - S E L E C T I O N ****************
************************************************************************
start-of-selection.
* Get the data from VBAK and VBAP Tables
perform get_vbak_vbap.
************************************************************************
****************** E N D - O F - S E L E C T I O N *****************
************************************************************************
end-of-selection.
* Display the data
perform dispolay_data.
*&---------------------------------------------------------------------*
*& Form get_vbak_vbap
*&---------------------------------------------------------------------*
* Get the data from VBAK and VBAP Table
*----------------------------------------------------------------------*
FORM get_vbak_vbap.
* Get the data from VBAK Table
select vbeln bstnk vdatu from vbak into table i_vbak
where vbeln in s_vbeln
and bstnk in s_bstnk
and vdatu in s_vdatu
and kunnr in s_kunnr
and erdat in s_erdat
and ernam in s_ernam.
if sy-subrc ne 0.
message e000(zwave) with 'No data found for given selection'.
endif.
* Get the data from VBAP Table
select a~vbeln a~matnr a~kdmat a~kwmeng a~netpr
b~maktx into table i_vbap
from vbap as a inner join makt as b on b~matnr = a~matnr
for all entries in i_vbak
where a~vbeln in s_vbeln
and a~kdmat in s_kdmat
and a~abgru = space
and a~matnr in s_matnr
and a~matnr ne '000000000000009999'
and a~matnr ne '000000000000004444'
and a~matnr ne '000000000000008888'
and a~matnr ne '000000000000001111'
and a~werks = '1000'
and b~spras = 'E'
and a~vbeln = i_vbak-vbeln.
if sy-subrc ne 0.
message e000(zwave) with 'No data found for given selection'.
endif.
sort i_vbak by vbeln.
sort i_vbap by vbeln matnr.
loop at i_vbap.
read table i_vbak with key vbeln = i_vbap-vbeln
binary search.
ENDFORM. " get_vbak_vbap
*&---------------------------------------------------------------------*
*& Form dispolay_data
*&---------------------------------------------------------------------*
* Display the data
*----------------------------------------------------------------------*
FORM dispolay_data.
* Fill the Fiedlcat
PERFORM fieldcat_init using gt_fieldcat[].
ENDFORM. " dispolay_data
*&---------------------------------------------------------------------*
*& Form fieldcat_init
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_FIELDCAT[] text
*----------------------------------------------------------------------*
FORM fieldcat_init USING e01_lt_fieldcat type slis_t_fieldcat_alv.
S_BSTNK Purchase Order
S_ERDAT Created on
S_ERNAM Created by
S_KDMAT Customer Material
S_KUNNR Customer
S_MATNR Material
S_VBELN Sales Order
S_VDATU Delivery date
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.