You are on page 1of 6

*&---------------------------------------------------------------------*

*& Report ZREPORT_HERTITAGE


*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZREPORT_HERTITAGE.
type-pools slis.
tables: vbak.
selection-screen begin of block b1 with frame TITLE text-100.
parameter p_plant type werks.
selection-screen skip 2.
SELECT-OPTIONS: s_spart for vbak-spart,
s_erdat for vbak-erdat.
selection-screen end of block b1.
types:
*begin
*
*
*
*

of strvbak,
vbeln type vbeln_va,
erdat type erdat,
spart type spart,
end of strvbak,
begin of strvbap,
vbeln type vbeln_va,
posnr type posnr_va,
matnr type matnr,
matkl type matkl,
spart type spart,
kwmeng type kwmeng,
werks type werks,
erdat type erdat,
end of strvbap,

begin of strvbep,
vbeln type vbeln,
posnr type posnr,
etenr type etenr,
* bmeng type bweng,
end of strvbep,

begin of strlikp,
vbeln type vbeln_vl,
lfart type lfart,
end of strlikp,
begin of strlips,
vbeln type vbeln_vl,
posnr type posnr_vl,
werks type werks,
vgbel type vgbel,
vgpos type vgpos,
mtart type mtart,
end of strlips,

begin of strvbrk,
vbeln_b type vbeln_vf,
end of strvbrk,
begin of strfinal,
vbeln type vbeln,
posnr type posnr,
matnr type matnr,
mtart type mtart,
matkl type matkl,
werks type werks,
spart type spart,
kwmeng type kwmeng,
*lfart type lfart,
bmeng type bmeng,
vbeln_b type vbeln_vf,
end of strfinal.
data :
*

w_vbak type strvbak,


w_vbap type strvbap,
w_lips type strlips,
w_likp type strlikp,
w_vbrk type strvbrk,
w_rbkp type strrbkp,
w_final type strfinal,
w_fcat type slis_fieldcat_alv.

data :

t_vbap type STANDARD TABLE OF strvbap,


t_lips type STANDARD TABLE OF strlips,
t_likp type STANDARD TABLE OF strlikp,
t_vbrk type STANDARD TABLE OF strvbrk,
t_rbkp TYPE STANDARD TABLE OF strrbkp,
t_final type STANDARD TABLE OF strfinal,
t_fcat type slis_t_fieldcat_alv.

AT SELECTION-SCREEN.
data : v_werks type werks,
v_spart type spart.
if p_plant is not initial.
select single werks from t001w into v_werks where werks = p_plant.
if sy-subrc <> 0.
message 'no plant found with this entry' type 'E'.
endif.
endif.
if s_spart is not initial.
select single spart from tspa into v_spart where spart in s_spart.
if sy-subrc <> 0.
message 'no spart with this entry' type 'E'.
endif.
endif.

START-OF-SELECTION.
select vbeln posnr matnr matkl spart kwmeng werks erdat from vbap into table t_v
bap where spart in s_spart and werks = p_plant
and erdat in s_erdat.
if sy-subrc <> 0 .
*
or p_plant is not initial or s_spart is not initial or s_erdat is not initi
al.
message 'no element found with this combination of entry ' type 'I'.
leave list-processing.
endif.
*

if t_vbap is not initial.


select

select vbeln posnr werks vgbel mtart from lips into table t_lips where werks =
p_plant .
if sy-subrc = 0.
sort t_lips by werks.
endif.
if t_lips is not initial.
select vbeln lfart from likp into table t_likp FOR ALL ENTRIES IN t_lips where
vbeln = t_lips-vbeln.
if sy-subrc <> 0.
message 'not delivery porduced yet' type 'I'.
endif.
endif.
endif.
end-of-SELECTION.
w_fcat-fieldname
w_fcat-seltext_m
w_fcat-outputlen
append w_fcat to
clear w_fcat.

= 'VBELN'.
= 'sales order'.
= '10'.
t_fcat.

w_fcat-fieldname = 'POSNR'.
w_fcat-seltext_m = 'item'.
w_fcat-outputlen = '10'.
append w_fcat to t_fcat.
clear w_fcat.

w_fcat-fieldname = 'MATNR'.
w_fcat-seltext_m = 'material'.
w_fcat-outputlen = '10'.
append w_fcat to t_fcat.
clear w_fcat.
w_fcat-fieldname
w_fcat-seltext_m
w_fcat-outputlen
append w_fcat to
clear w_fcat.

= 'MTART'.
= 'material type'.
= '10'.
t_fcat.

w_fcat-fieldname
w_fcat-seltext_m
w_fcat-outputlen
append w_fcat to
clear w_fcat.

= 'MATKL'.
= 'material group'.
= '20'.
t_fcat.

w_fcat-fieldname
w_fcat-seltext_m
w_fcat-outputlen
append w_fcat to
clear w_fcat.

= 'WERKS'.
= 'plant'.
= '10'.
t_fcat.

w_fcat-fieldname
w_fcat-seltext_m
w_fcat-outputlen
append w_fcat to
clear w_fcat.

= 'SPART'.
= 'division'.
= '10'.
t_fcat.

w_fcat-fieldname = 'KWMENG'.
w_fcat-seltext_m = 'ordr qnty'.
w_fcat-outputlen = '10'.
append w_fcat to t_fcat.
clear w_fcat.
w_fcat-fieldname
w_fcat-seltext_m
w_fcat-outputlen
append w_fcat to
clear w_fcat.

= 'LFART'.
= 'delivery'.
= '10'.
t_fcat.

w_fcat-fieldname = 'VBELN_VF'.
w_fcat-seltext_m = 'biiling doc'.
w_fcat-outputlen = '10'.
append w_fcat to t_fcat.
clear w_fcat.

*
*
*
*
*

w_fcat-fieldname
w_fcat-seltext_m
w_fcat-outputlen
append w_fcat to
clear w_fcat.

= 'VBELN'.
= 'sales order'.
= '10'.
t_fcat.

loop at t_vbap into w_vbap.


w_final-vbeln = w_vbap-vbeln.
w_final-posnr = w_vbap-posnr.
w_final-matnr = w_vbap-matnr.
w_final-mtart = w_lips-mtart.
w_final-matkl = w_vbap-matkl.
w_final-werks = w_vbap-werks.
w_final-spart = w_vbap-spart.
w_final-kwmeng = w_vbap-kwmeng.
* w_final-bmeng = w_vbep-bmeng.
w_final-vbeln_b = w_vbrk-vbeln_b.
append w_final to t_final.
clear w_final.

endloop.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING
* I_INTERFACE_CHECK
= ' '
* I_BYPASSING_BUFFER
= ' '
* I_BUFFER_ACTIVE
= ' '
I_CALLBACK_PROGRAM
= sy-cprog
* I_CALLBACK_PF_STATUS_SET
= ' '
* I_CALLBACK_USER_COMMAND
= ' '
I_CALLBACK_TOP_OF_PAGE
= 'ZHEAD'
* 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
= t_fcat
* 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
* 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
= t_final
* EXCEPTIONS
* PROGRAM_ERROR
= 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.
form ZHEAD .
data :w_head type slis_listheader,
t_head type slis_t_listheader.
w_head-typ = 'H'.
w_head-info = 'SALES order'.
append w_head to t_head.

clear w_head.
w_head-typ = 'A'.
w_head-info = 'PLANT:'.
*CONCATENATE p_plant+4(3)
*into w_head.
append w_head to t_head.
clear w_head.
w_head-typ = 'S'.
w_head-info = 'DATE:'.
*CONCATENATE sy-datum+6(2) '.'
*sy-datum+4(2) '.'
*sy-datum(4) INTO w_head.
append w_head to t_head.
clear w_head.
W_head-typ = 'A'.
w_head-info = 'DIVISION:'.
*w_head-info = w_vbap-spart.
append w_head to t_head.
clear w_head.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY
= t_head
* I_LOGO
=
* I_END_OF_LIST_GRID
=
* I_ALV_FORM
=
.
endform.

You might also like