ALV Report
ALV Report
ALV Report
zdemo_alv1_po.
*---------------------------------------------*
*
ALV DECLARATION
*
*---------------------------------------------*
* alv Declaration
*fieldcat
DATA: gt_fcat TYPE slis_t_fieldcat_alv,
gs_fcat TYPE slis_fieldcat_alv.
*top of page
DATA: gt_top
gs_top
TYPE slis_t_listheader,
TYPE slis_listheader.
*layout.
DATA: gs_lay
TYPE slis_layout_alv.
*sort
DATA: gt_sort TYPE slis_t_sortinfo_alv ,
gs_sort TYPE slis_sortinfo_alv.
*---------------------------------------------*
*
SELECTION-SCREEN
*
*---------------------------------------------*
SELECT-OPTIONS : s_ebeln FOR ekpo-ebeln,
s_matnr FOR ekpo-matnr.
AT SELECTION-SCREEN.
IF s_ebeln IS INITIAL
AND
s_matnr IS INITIAL.
flag = 'A'.
MESSAGE 'enter atleast value in one field' TYPE 'E'.
ENDIF.
IF s_ebeln IS INITIAL .
flag = 'B'.
SELECT SINGLE matnr FROM ekpo INTO v_matnr
WHERE matnr IN s_matnr.
ENDIF.
IF s_matnr IS INITIAL.
flag = 'C'.
SELECT SINGLE ebeln FROM ekpo INTO v_ebeln
WHERE ebeln IN s_ebeln.
ENDIF.
*---------------------------------------------*
*
START-OF-SELECTION
*
*---------------------------------------------*
START-OF-SELECTION.
PERFORM data_selection.
PERFORM data_manupulation.
PERFORM data_dispaly.
*&---------------------------------------------------------------------*
*&
Form data_selection
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM data_selection .
SELECT ebeln
ebelp
matnr
werks
FROM ekpo
INTO TABLE gt_final
WHERE ebeln IN s_ebeln
AND
matnr IN s_matnr.
IF gt_final[] IS NOT INITIAL.
SELECT ebeln
bukrs
bstyp
bsart
FROM ekko INTO TABLE gt_ekko
FOR ALL ENTRIES IN gt_final
WHERE ebeln = gt_final-ebeln.
ENDIF.
ENDFORM.
" data_selection
*&---------------------------------------------------------------------*
*&
Form data_manupulation
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM data_manupulation .
LOOP AT gt_final INTO gs_final.
READ TABLE gt_ekko INTO gs_ekko WITH KEY ebeln = gs_final-ebeln.
IF sy-subrc EQ 0.
gs_final-bukrs = gs_ekko-bukrs.
gs_final-bstyp = gs_ekko-bstyp.
gs_final-bsart = gs_ekko-bsart.
MODIFY gt_final FROM gs_final.
HIDE: gs_final-matnr,
gs_final-ebeln.
ENDIF.
ENDLOOP.
ENDFORM.
" data_manupulation
*&---------------------------------------------------------------------*
*&
Form data_dispaly
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM data_dispaly .
CLEAR: gt_fcat,
gs_fcat.
gs_fcat-row_pos
= 1.
gs_fcat-tabname
= 'gt_final'.
gs_fcat-fieldname
= 'EBELN'.
gs_fcat-outputlen
= '12'.
gs_fcat-seltext_l
= 'Purchasing Document Number'.
APPEND gs_fcat TO gt_fcat.
gs_fcat-row_pos
gs_fcat-tabname
gs_fcat-fieldname
gs_fcat-outputlen
=
=
=
=
2.
'gt_final'.
'MATNR'.
'20'.
gs_fcat-seltext_l
= 'Material Number'.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
gs_fcat-row_pos
= 3.
gs_fcat-tabname
= 'gt_final'.
gs_fcat-fieldname
= 'EBELP'.
gs_fcat-seltext_l
= 'Item Number of Purchasing Document'.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
gs_fcat-row_pos
= 4.
gs_fcat-tabname
= 'gt_final'.
gs_fcat-fieldname
= 'WERKS'.
gs_fcat-outputlen
= '10'.
gs_fcat-seltext_l
= 'Plant'.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
gs_fcat-row_pos
= 5.
gs_fcat-tabname
= 'gt_final'.
gs_fcat-fieldname
= 'BUKRS'.
gs_fcat-outputlen
= '13'.
gs_fcat-seltext_l
= 'Company Code'.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
gs_fcat-row_pos
= 6.
gs_fcat-tabname
= 'gt_final'.
gs_fcat-fieldname
= 'BSTYP'.
gs_fcat-outputlen
= '16'.
gs_fcat-seltext_l
= 'Purchasing Document Category'.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
*
gs_fcat-row_pos
= 7.
gs_fcat-tabname
= 'gt_final'.
gs_fcat-fieldname
= 'BSART'.
gs_fcat-outputlen
= '16'.
gs_fcat-seltext_l
= 'Purchasing Document Type'.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
*layout.
CLEAR gs_lay.
gs_lay-colwidth_optimize = 'X'.
gs_lay-zebra
= 'X'.
gs_lay-no_colhead
= ''.
CLEAR : gt_sort ,
gs_sort .
IF flag = 'B'.
gs_sort-spos = '2'.
gs_sort-fieldname = 'MATNR'.
APPEND gs_sort
TO gt_sort .
ELSE.
gs_sort-spos = '1'.
gs_sort-fieldname = 'EBELN'.
APPEND gs_sort
TO gt_sort .
ENDIF.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
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
= gt_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.
ENDFORM.
" data_dispaly
"data_dispaly
*&---------------------------------------------------------------------*
*&
Form top_of_page
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM top_of_page .
CLEAR: gs_top,
gt_top.
DATA: v_datl(10),
v_dath(10).
gs_top-typ = 'H'.
gs_top-key = 'Report:'.
gs_top-info = 'Purchasing Data header Report'.
APPEND gs_top TO gt_top.
CLEAR gs_top.
IF flag = 'C'.
IF s_ebeln-high IS INITIAL.
CLEAR gs_top.
gs_top-typ =
gs_top-key =
gs_top-info =
APPEND gs_top
CLEAR gs_top.
ENDIF.
'S'.
'Customer:'.
s_ebeln-low.
TO gt_top.
IF s_matnr-high
CLEAR gs_top.
gs_top-typ =
gs_top-key =
gs_top-info =
APPEND gs_top
CLEAR gs_top.
ENDIF.
IS INITIAL.
'S'.
'Matrial:'.
s_matnr-low.
TO gt_top.
= 'S'.
= 'S'.
= 'Material
:'.
" top_of_page