SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Sales Order ALV report



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sat Sep 29, 2007 2:33 pm    Post subject: Sales Order ALV report Reply with quote

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.

if sy-subrc eq 0.

i_sales-bstnk = i_vbak-bstnk.
i_sales-vdatu = i_vbak-vdatu.
i_sales-matnr = i_vbap-matnr.
i_sales-kdmat = i_vbap-kdmat.
i_sales-maktx = i_vbap-maktx.
i_sales-netpr = i_vbap-netpr.
i_sales-kwmeng = i_vbap-kwmeng.
append i_sales.
else.
continue.
endif.

clear : i_sales,
i_vbap,
i_vbak.

endloop.

sort i_sales by vdatu bstnk matnr.

refresh : i_vbap,
i_vbak.

ENDFORM. " get_vbak_vbap
*&---------------------------------------------------------------------*
*& Form dispolay_data
*&---------------------------------------------------------------------*
* Display the data
*----------------------------------------------------------------------*
FORM dispolay_data.

* Fill the Fiedlcat
PERFORM fieldcat_init using gt_fieldcat[].

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = v_repid
* 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 = gt_fieldcat[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_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
* IT_ALV_GRAPHICS =
* IT_ADD_FIELDCAT =
* IT_HYPERLINK =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IT_EXCEPT_QINFO =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = i_sales
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.


ENDFORM. " dispolay_data
*&---------------------------------------------------------------------*
*& Form fieldcat_init
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_FIELDCAT[] text
*----------------------------------------------------------------------*
FORM fieldcat_init USING e01_lt_fieldcat type slis_t_fieldcat_alv.


DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.


* Delivery Date
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'VDATU'.
LS_FIELDCAT-OUTPUTLEN = 12.
LS_FIELDCAT-TABNAME = 'I_SALES'.
ls_fieldcat-seltext_L = 'Delivery Date'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

* Purchase Order #Material Description
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'BSTNK'.
LS_FIELDCAT-OUTPUTLEN = 25.
LS_FIELDCAT-TABNAME = 'I_SALES'.
ls_fieldcat-seltext_L = 'Purchase Order #'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

* Material
CLEAR LS_FIELDCAT.
LS_FIELDCAT-REF_FIELDNAME = 'MATNR'.
LS_FIELDCAT-REF_TABNAME = 'MARA'.
LS_FIELDCAT-FIELDNAME = 'MATNR'.
LS_FIELDCAT-TABNAME = 'I_SALES'.
ls_fieldcat-seltext_L = 'Material #'.
ls_fieldcat-seltext_M = 'Material #'.
ls_fieldcat-seltext_S = 'Material #'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.


* Material Description
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MAKTX'.
LS_FIELDCAT-OUTPUTLEN = 40.
LS_FIELDCAT-TABNAME = 'I_SALES'.
ls_fieldcat-seltext_L = 'Material Description'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

* Customer Material #
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'KDMAT'.
LS_FIELDCAT-OUTPUTLEN = 35.
LS_FIELDCAT-TABNAME = 'I_SALES'.
ls_fieldcat-seltext_L = 'Customer material no.'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.


* Quantity
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'KWMENG'.
LS_FIELDCAT-OUTPUTLEN = 15.
LS_FIELDCAT-TABNAME = 'I_SALES'.
ls_fieldcat-seltext_L = 'Quantity'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

* Net Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'NETPR'.
LS_FIELDCAT-OUTPUTLEN = 15.
LS_FIELDCAT-TABNAME = 'I_SALES'.
ls_fieldcat-seltext_L = 'Net Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.





ENDFORM. " fieldcat_init

Text elements :

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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.