* This program will display the data for the PO with RFQ
*-----------------------------------------------------*
REPORT zmm_po_status_report.
TYPE-POOLS: slis.
TABLES: ekko, ekpo.
TYPES: BEGIN OF ty_eban,
banfn TYPE eban-banfn,
bnfpo TYPE eban-bnfpo,
ebeln TYPE eban-ebeln,
ebelp TYPE eban-ebelp,
END OF ty_eban.
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_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,
netpr TYPE ekpo-netpr,
abskz TYPE ekpo-abskz,
elikz TYPE ekpo-elikz,
erekz TYPE ekpo-erekz,
wepos TYPE ekpo-wepos,
repos TYPE ekpo-repos,
webre TYPE ekpo-webre,
lmein TYPE ekpo-lmein,
sobkz TYPE ekpo-sobkz,
END OF ty_ekpo.
TYPES: BEGIN OF ty_ekko,
ebeln TYPE ekko-ebeln,
waers TYPE ekko-waers,
END OF ty_ekko.
TYPES: BEGIN OF ty_makt,
matnr TYPE mara-matnr,
maktx TYPE makt-maktx,
END OF ty_makt.
TYPES: BEGIN OF ty_final,
banfn TYPE eban-banfn,
bnfpo TYPE eban-bnfpo,
aedat TYPE ekpo-aedat,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
maktx TYPE makt-maktx,
menge TYPE ekpo-menge,
menge1 TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
waers TYPE ekko-waers,
werks TYPE ekpo-werks,
lgort TYPE ekpo-lgort,
remark 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_ekko TYPE TABLE OF ty_ekko 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_ebeln FOR ekko-ebeln,
s_aedat FOR ekko-aedat,
s_werks FOR ekpo-werks.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM get_ekko_data.
PERFORM get_ekpo_data.
PERFORM get_eban_data.
PERFORM get_ekbe_data.
PERFORM get_makt_data.
END-OF-SELECTION.
PERFORM process_data.
PERFORM prepare_fieldcat.
PERFORM display_alv.
*&---------------------------------------------------------------------*
*& Form GET_EKKO_DATA
*----------------------------------------------------------------------*
FORM get_ekko_data .
SELECT ebeln
waers
FROM ekko
INTO TABLE it_ekko
WHERE ebeln IN s_ebeln
AND aedat IN s_aedat.
IF sy-subrc = 0.
SORT it_ekko BY ebeln.
ENDIF.
ENDFORM. " GET_EKKO_DATA
*&---------------------------------------------------------------------*
*& Form GET_EKPO_DATA
*----------------------------------------------------------------------*
FORM get_ekpo_data .
SELECT ebeln
ebelp
statu
aedat
matnr
bukrs
werks
lgort
menge
meins
netpr
abskz
elikz
erekz
wepos
repos
webre
lmein
sobkz
FROM ekpo
INTO TABLE it_ekpo
FOR ALL ENTRIES IN it_ekko
WHERE ebeln = it_ekko-ebeln
AND werks IN s_werks.
IF sy-subrc = 0.
SORT it_ekpo BY ebeln ebelp.
ENDIF.
ENDFORM. " GET_EKPO_DATA
*&---------------------------------------------------------------------*
*& Form GET_EBAN_DATA
*----------------------------------------------------------------------*
FORM get_eban_data .
SELECT banfn
bnfpo
ebeln
ebelp
FROM eban
INTO TABLE it_eban
FOR ALL ENTRIES IN it_ekpo
WHERE ebeln = it_ekpo-ebeln
AND ebelp = it_ekpo-ebelp
AND matnr = it_ekpo-matnr.
IF sy-subrc = 0.
SORT it_eban BY ebeln ebelp.
ENDIF.
ENDFORM. " GET_EBAN_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 PROCESS_DATA
*----------------------------------------------------------------------*
FORM process_data .
LOOP AT it_ekpo.
it_final-ebeln = it_ekpo-ebeln.
it_final-ebelp = it_ekpo-ebelp.
it_final-menge = it_ekpo-menge.
it_final-meins = it_ekpo-meins.
it_final-werks = it_ekpo-werks.
it_final-lgort = it_ekpo-lgort.
it_final-aedat = it_ekpo-aedat.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = it_ekpo-matnr
IMPORTING
output = it_final-matnr.
READ TABLE it_eban WITH KEY ebeln = it_ekpo-ebeln
ebelp = it_ekpo-ebelp.
IF sy-subrc = 0.
it_final-banfn = it_eban-banfn.
it_final-bnfpo = it_eban-bnfpo.
ENDIF.
READ TABLE it_makt WITH KEY matnr = it_ekpo-matnr.
IF sy-subrc = 0.
it_final-maktx = it_makt-maktx.
ENDIF.
READ TABLE it_ekko WITH KEY ebeln = it_ekpo-ebeln.
IF sy-subrc = 0.
it_final-waers = it_ekko-waers.
ENDIF.
LOOP AT it_ekbe WHERE ebeln = it_eban-ebeln
AND ebelp = it_eban-ebelp.
CASE : it_ekbe-bewtp.
WHEN 'E'.
it_final-menge1 = it_final-menge1 + it_ekbe-menge.
ENDCASE.
ENDLOOP.
it_final-menge1 = it_final-menge - it_final-menge1.
CLEAR : it_final-remark.
APPEND it_final.
CLEAR it_final.
ENDLOOP.
ENDFORM. " PROCESS_DATA
*&---------------------------------------------------------------------*
*& Form PREPARE_FIELDCAT
*----------------------------------------------------------------------*
FORM prepare_fieldcat .
PERFORM build_fieldcat USING : 'BANFN' 'PR Number',
'BNFPO' 'PR Item',
'AEDAT' 'PO Date',
'EBELN' 'PO Number',
'EBELP' 'PO Item',
'MATNR' 'Material',
'MAKTX' 'Material Desc',
'MENGE' 'PO Quantity',
'MENGE1' 'PO Qty Pending',
'MEINS' 'Unit',
'NETPR' 'Net Price',
'WAERS' 'Currency',
'WERKS' 'Plant',
'LGORT' 'Stor Loc',
'REMARK' 'Remarks'.
ENDFORM. " PREPARE_FIELDCAT
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCAT
*----------------------------------------------------------------------*
FORM build_fieldcat USING value(p_0491)
value(p_0492).
wa_fieldcat-fieldname = p_0491.
wa_fieldcat-reptext_ddic = p_0492.
wa_fieldcat-tabname = 'IT_FINAL'.
IF wa_fieldcat-fieldname = 'MATNR' OR wa_fieldcat-fieldname = 'MAKTX'.
wa_fieldcat-just = 'L'.
ELSE.
wa_fieldcat-just = 'C'.
ENDIF.
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 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 Header'.
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 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
*&---------------------------------------------------------------------*
*& 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
ALSO READ:
- Create Unique Handle For ALV Layout (Variant).
- Customizing Toolbar In ALV Tree Using ABAP OO.
- Dropdown in ALV Grid Display.
- SALV List With Check Box.
- SALV List With Symbol.
..... Back To Index On ALV List/ Grid Display.
..... Back To MAIN INDEX.
I think its a great tutorial.
ReplyDelete