TYPE-POOLS: slis.
TABLES: eban.
TYPES: BEGIN OF ty_eban,
banfn TYPE eban-banfn,
bnfpo TYPE eban-bnfpo,
bsart TYPE eban-bsart,
statu TYPE eban-statu,
ernam TYPE eban-ernam,
erdat TYPE eban-erdat,
afnam TYPE eban-afnam,
matnr TYPE eban-matnr,
werks TYPE eban-werks,
lgort TYPE eban-lgort,
menge TYPE eban-menge,
meins TYPE eban-meins,
badat TYPE eban-badat,
lfdat TYPE eban-lfdat,
frgdt TYPE eban-frgdt,
ebeln TYPE eban-ebeln,
ebelp TYPE eban-ebelp,
END OF ty_eban.
TYPES: BEGIN OF ty_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
bukrs TYPE ekpo-bukrs,
werks TYPE ekpo-werks,
lgort TYPE ekpo-lgort,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
END OF ty_ekpo.
TYPES: BEGIN OF ty_makt,
matnr TYPE mara-matnr,
maktx TYPE makt-maktx,
END OF ty_makt.
TYPES: BEGIN OF ty_ekbe,
ebeln TYPE ekbe-ebeln,
ebelp TYPE ekbe-ebelp,
bewtp TYPE ekbe-bewtp,
menge TYPE ekbe-menge,
matnr TYPE ekbe-matnr,
bldat TYPE ekbe-bldat,
END OF ty_ekbe.
TYPES: BEGIN OF ty_final,
banfn TYPE eban-banfn,
bnfpo TYPE eban-bnfpo,
bsart TYPE eban-bsart,
statu TYPE eban-statu,
ernam TYPE eban-ernam,
erdat TYPE eban-erdat,
afnam TYPE eban-afnam,
matnr TYPE eban-matnr,
werks TYPE eban-werks,
lgort TYPE eban-lgort,
menge TYPE eban-menge,
meins TYPE eban-meins,
badat TYPE eban-badat,
lfdat TYPE eban-lfdat,
frgdt TYPE eban-frgdt,
ebeln TYPE eban-ebeln,
ebelp TYPE eban-ebelp,
menge1 TYPE eban-menge,
meins1 TYPE eban-meins,
maktx TYPE makt-maktx,
text TYPE char40,
qty1 TYPE eban-menge,
qty2 TYPE eban-menge,
qty3 TYPE eban-menge,
remarks type char50,
END OF ty_final.
DATA: it_eban TYPE TABLE OF ty_eban WITH HEADER LINE,
it_makt TYPE TABLE OF ty_makt WITH HEADER LINE,
it_ekpo TYPE TABLE OF ty_ekpo WITH HEADER LINE,
it_ekbe TYPE TABLE OF ty_ekbe WITH HEADER LINE,
it_final TYPE TABLE OF ty_final WITH HEADER LINE.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat LIKE LINE OF it_fieldcat,
it_layout TYPE slis_layout_alv,
it_events TYPE slis_t_event,
wa_events LIKE LINE OF it_events,
it_list TYPE slis_t_listheader WITH HEADER LINE.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_banfn FOR eban-banfn,
s_erdat FOR eban-erdat,
s_werks FOR eban-werks.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM get_eban_data.
PERFORM get_ekpo_data.
PERFORM get_makt_data.
PERFORM get_ekbe_data.
END-OF-SELECTION.
DATA: values_tab TYPE TABLE OF dd07v WITH HEADER LINE,
v_menge1 TYPE eban-menge,
v_menge2 TYPE eban-menge,
v_menge3 TYPE eban-menge.
PERFORM get_status_text.
PERFORM process_data.
PERFORM prepare_fieldcat.
PERFORM display_alv.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCAT
*----------------------------------------------------------------------*
FORM build_fieldcat USING p_field
p_desc.
wa_fieldcat-fieldname = p_field.
wa_fieldcat-reptext_ddic = p_desc.
wa_fieldcat-tabname = 'IT_FINAL'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV
*----------------------------------------------------------------------*
FORM display_alv .
it_layout-zebra = 'X'.
it_layout-colwidth_optimize = 'X'.
wa_events-form = 'TOP_OF_PAGE'.
wa_events-name = 'TOP_OF_PAGE'.
append wa_events to it_events.
clear wa_events.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_GRID_TITLE =
is_layout = it_layout
it_fieldcat = it_fieldcat
it_events = it_events
TABLES
t_outtab = it_final
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " DISPLAY_ALV
*&---------------------------------------------------------------------*
*& Form GET_EBAN_DATA
*----------------------------------------------------------------------*
FORM get_eban_data .
SELECT banfn
bnfpo
bsart
statu
ernam
erdat
afnam
matnr
werks
lgort
menge
meins
badat
lfdat
frgdt
ebeln
ebelp
FROM eban
INTO TABLE it_eban
WHERE banfn IN s_banfn
AND erdat IN s_erdat
AND werks IN s_werks.
IF sy-subrc = 0.
SORT it_eban BY banfn bnfpo.
ENDIF.
ENDFORM. " GET_EBAN_DATA
*&---------------------------------------------------------------------*
*& Form GET_EKPO_DATA
*----------------------------------------------------------------------*
FORM get_ekpo_data .
IF NOT it_eban[] IS INITIAL.
SELECT
ebeln
ebelp
statu
aedat
matnr
bukrs
werks
lgort
menge
meins
FROM ekpo
INTO TABLE it_ekpo
FOR ALL ENTRIES IN it_eban
WHERE ebeln = it_eban-ebeln
AND ebelp = it_eban-ebelp.
IF sy-subrc = 0.
SORT it_ekpo BY ebeln ebelp.
ENDIF.
ENDIF.
ENDFORM. " GET_EKPO_DATA
*&---------------------------------------------------------------------*
*& Form GET_MAKT_DATA
*----------------------------------------------------------------------*
FORM get_makt_data .
SELECT matnr
maktx
FROM makt
INTO TABLE it_makt
FOR ALL ENTRIES IN it_ekpo
WHERE matnr = it_ekpo-matnr
AND spras = 'EN'.
IF sy-subrc = 0.
SORT it_makt BY matnr.
ENDIF.
ENDFORM. " GET_MAKT_DATA
*&---------------------------------------------------------------------*
*& Form GET_EKBE_DATA
*----------------------------------------------------------------------*
FORM get_ekbe_data .
SELECT ebeln
ebelp
bewtp
menge
matnr
bldat
FROM ekbe
INTO TABLE it_ekbe
FOR ALL ENTRIES IN it_ekpo
WHERE ebeln = it_ekpo-ebeln
AND ebelp = it_ekpo-ebelp.
IF sy-subrc = 0.
SORT it_ekbe BY ebeln ebelp.
ENDIF.
ENDFORM. " GET_EKBE_DATA
*&---------------------------------------------------------------------*
*& Form GET_STATUS_TEXT
*----------------------------------------------------------------------*
FORM get_status_text .
CALL FUNCTION 'GET_DOMAIN_VALUES'
EXPORTING
domname = 'BANST'
text = 'X'
TABLES
values_tab = values_tab
EXCEPTIONS
no_values_found = 1
OTHERS = 2.
ENDFORM. " GET_STATUS_TEXT
*&---------------------------------------------------------------------*
*& Form PROCESS_DATA
*----------------------------------------------------------------------*
FORM process_data .
LOOP AT it_eban.
MOVE-CORRESPONDING it_eban TO it_final.
READ TABLE values_tab WITH KEY domvalue_l = it_eban-statu.
IF sy-subrc = 0.
it_final-text = values_tab-ddtext.
ENDIF.
READ TABLE it_ekpo WITH KEY ebeln = it_eban-ebeln
ebelp = it_eban-ebelp.
IF sy-subrc = 0.
it_final-menge1 = it_ekpo-menge.
it_final-meins1 = it_ekpo-meins.
ENDIF.
READ TABLE it_makt WITH KEY matnr = it_final-matnr.
IF sy-subrc = 0.
it_final-maktx = it_makt-maktx.
ENDIF.
LOOP AT it_ekbe WHERE ebeln = it_eban-ebeln
AND ebelp = it_eban-ebelp
AND matnr = it_eban-matnr.
CASE : it_ekbe-bewtp.
WHEN 'E'.
v_menge1 = v_menge1 + it_ekbe-menge.
WHEN 'R'.
v_menge2 = v_menge2 + it_ekbe-menge.
ENDCASE.
ENDLOOP.
it_final-qty1 = v_menge2.
it_final-qty2 = it_final-menge1 - v_menge2 .
it_final-qty3 = it_final-menge - v_menge2 .
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = it_final-matnr
IMPORTING
output = it_final-matnr.
APPEND it_final.
CLEAR: it_final,
v_menge1,
v_menge2.
ENDLOOP.
ENDFORM. " PROCESS_DATA
*&---------------------------------------------------------------------*
*& Form PREPARE_FIELDCAT
*----------------------------------------------------------------------*
FORM prepare_fieldcat .
PERFORM build_fieldcat USING : 'FRGDT' 'PR Date',
'LFDAT' 'Delivery Date',
'AFNAM' 'Requested By',
'ERNAM' 'PR Created By',
'BANFN' 'PR Number',
'BNFPO' 'Item No',
'MATNR' 'Material',
'MAKTX' 'Material Desc',
'MENGE' 'PR Quantity',
'MEINS' 'Unit',
'BEDAT' 'PO Date',
'EBELN' 'PO Number',
'EBELP' 'PO Item',
'MENGE1' 'PO Quantity',
'QTY1' 'Qty Delevered',
'QTY2' 'PO Qty Pending',
'QTY3' 'PR Qty Pending',
'WERKS' 'Plant',
'LGORT' 'Stor Loc',
'TEXT' 'PR Status',
'REMARK' 'Remarks'.
ENDFORM. " PREPARE_FIELDCAT
*&--------------------------------------------------------------------*
*& Form top_of_page
*&--------------------------------------------------------------------*
* get the top-of-page and display
*---------------------------------------------------------------------*
FORM top_of_page.
*--Display the header of the report
perform HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_list[]
I_LOGO = 'ZLOGO2'.
ENDFORM. "top_of_page
*&---------------------------------------------------------------------*
*& Form HEADER
*&---------------------------------------------------------------------*
* Get the header of the alv
*----------------------------------------------------------------------*
FORM header .
*----variables for output header of the alv
DATA : date_s(10), date_e(10).
DATA: company_name(50) TYPE c VALUE 'Company Name'.
DATA : head_line(60) TYPE c.
DATA : today(10) TYPE c.
DATA : curr_time(10) TYPE c.
DATA : page_no(5) TYPE c.
DATA : len TYPE i.
DATA : wa_num1 TYPE i.
DATA : wa_num2 TYPE i.
DATA : pos TYPE i.
DATA : linex TYPE i,
v_stext(40), " Initial Template Id text
v_f4flag TYPE c.
WRITE sy-datum MM/DD/YYYY TO today.
WRITE sy-uzeit TO curr_time.
WRITE sy-pagno TO page_no LEFT-JUSTIFIED.
REFRESH it_list.
CLEAR it_list.
*---- REPORT PROGRAM NAME AND CLINT
it_list-typ = 'S'.
it_list-key = space.
CONCATENATE 'Report...:' sy-repid '(' sy-sysid(3) sy-mandt ')'
INTO it_list-info SEPARATED BY space.
APPEND it_list TO it_list.
*---- USER NAME
CLEAR it_list.
it_list-typ = 'S'.
it_list-key = space.
CONCATENATE 'User.....:' sy-uname
INTO it_list-info SEPARATED BY space.
APPEND it_list TO it_list.
*------DATE / TIME STAMP
CLEAR it_list.
it_list-typ = 'S'.
it_list-key = space.
CONCATENATE 'Date/Time:' today curr_time
INTO it_list-info SEPARATED BY space.
APPEND it_list TO it_list.
*------PAGE NUMBER
CLEAR it_list.
it_list-typ = 'S'.
it_list-key = space.
CONCATENATE 'Page.....:' page_no
INTO it_list-info SEPARATED BY space.
APPEND it_list TO it_list.
CLEAR it_list.
it_list-typ = 'S'.
it_list-key = space.
CONCATENATE ' ' ' '
INTO it_list-info SEPARATED BY space.
APPEND it_list TO it_list.
*------COMPANY NAME
* determine the starting position to center the company name
len = STRLEN( company_name ).
wa_num1 = 60 - len.
pos = wa_num1 / 2.
IF pos LT 1.
pos = 1.
ENDIF.
len = 60 - pos.
CLEAR it_list.
it_list-typ = 'H'.
it_list-key = space.
it_list-info+pos(len) = company_name.
APPEND it_list TO it_list.
*-------REPORT TITLE
data: v_string type char40.
v_string = 'Test Progarm Header'.
* determine the starting position to center the report title
len = STRLEN( v_string ).
wa_num1 = 60 - len.
pos = wa_num1 / 2.
IF pos LT 1.
pos = 1.
ENDIF.
len = 60 - pos.
CLEAR it_list.
it_list-typ = 'H'.
it_list-key = space.
it_list-info+pos(len) = v_string.
APPEND it_list TO it_list.
* determine the starting position to center the report title
len = STRLEN( sy-title ).
wa_num1 = 60 - len.
pos = wa_num1 / 2.
IF pos LT 1.
pos = 1.
ENDIF.
len = 60 - pos.
CLEAR it_list.
it_list-typ = 'H'.
it_list-key = space.
it_list-info+pos(len) = sy-title.
APPEND it_list TO it_list.
len = STRLEN( head_line ).
wa_num1 = 60 - len.
pos = wa_num1 / 2.
IF pos LT 1.
pos = 1.
ENDIF.
len = 60 - pos.
CLEAR it_list.
it_list-typ = 'H'.
it_list-info+pos(len) = head_line.
APPEND it_list.
CLEAR it_list.
ENDFORM. " HEADER
ALSO READ:
- Handling Radio Buttons in SALV Tree Display.
- Display The PO Status In ALV Report - MM.
- SALV List With Check Box.
- SALV List With Symbol.
..... Back To Index On ALV List/ Grid Display.
..... Back To MAIN INDEX.
No comments:
Post a Comment