2007 Feb 14 6:58 AM
Hi experts,
Can anyone please provide some code which uses the classes <b>cl_gui_custom_conta</b>iner,<b>cl_gui_alv_grid</b>, to get a better understanding about how to use these classes.
Thanks in advance,
regards
Ashwin
2007 Feb 14 7:00 AM
Refer to the demo programs available in
<b>SE38 > Environment > control examples.</b>
This wil help u a lot.
Hi experts,
Can anyone please provide some code which uses the classes <b>cl_gui_custom_conta</b>iner,<b>cl_gui_alv_grid</b>, to get a better understanding about how to use these classes.
Thanks in advance,
regards
Ashwin
2007 Feb 14 7:00 AM
Refer to the demo programs available in
<b>SE38 > Environment > control examples.</b>
This wil help u a lot.
2007 Feb 14 7:00 AM
2007 Feb 14 7:01 AM
HI,
REPORT zfro_unplanned_del_cost
MESSAGE-ID zf_ebb1
NO STANDARD PAGE HEADING.
----
Description :Report Program that lists the Freight Costs
(Unplanned Delivery)
Module :Financial Accounting - AP
Technical Contact :Subramanian.PL
Functional Contact :
Technical Spec. Number:
Created on :10/21/2005
Transport Req. :D10K916623
Development Class :ZZFI
----
----
Form History
----
Form f0001_initialize_val Initialize Current Period and Month
Form f0002_create_header To Populate output to final table
Form f0003_create_container To Create Container
Form f0004_merge_document To merge document with the header
Form f0005_build_field_catalog To Build a Field Catalog
Form f0006_alv_layout_options Layout Options
Form f0007_display_data To Display The Data in ALV format
Form f0008_get_posting_period Get the Posting Period from the
Invoicing Date
Form f0009_get_data_from_rseg Fetch corresponding data from RSEG
*
----
----
Includes
----
INCLUDE zfro_unplanned_report_top. "TOP INCLUDE
*
INCLUDE zfro_unplanned_report_sel. "SELECTION SCREEN INCLUDE
INCLUDE zfro_unplanned_class_impl. "Class Definition & Implementation
*
INCLUDE zfro_unplanned_report_sos . "Start Of Selection Include
*
INCLUDE zfro_unplanned_report_eos . "End Of Selection Include
*
INCLUDE zfro_unplanned_report_forms . "FORMS Include
*
-
----
INCLUDE ZFRO_UNPLANNED_REPORT_TOP *
----
----
T A B L E S D E C L A R A T I O N *
----
TABLES: lfa1,
t001w,
bkpf,
ekko,
rbkp.
----
D A T A D E C L A R A T I O N *
----
*DATA: ws_budat LIKE rbkp-budat.
DATA: ws_gjahr LIKE bkpf-gjahr, "#EC NEEDED
ws_monat LIKE bkpf-monat.
DATA: ws_beznk LIKE rbkp-beznk.
DATA: ws_begda LIKE t549q-begda,
ws_endda LIKE t549q-endda.
DATA: BEGIN OF i_rbkp OCCURS 0,
belnr LIKE rbkp-belnr, "Document Number
budat LIKE rbkp-budat, "Posting Date
gjahr LIKE rbkp-gjahr, "Fiscal Year
beznk LIKE rbkp-beznk, "Unplanned delivery costs
xblnr LIKE rbkp-xblnr, "Ref.Document No.
bldat LIKE rbkp-bldat, "Document Date
waers LIKE rbkp-waers, "Currency Key
ebeln LIKE rseg-ebeln, "Purchasing Document Number
ebelp LIKE rseg-ebelp, "Item Number
werks LIKE rseg-werks, "Plant
END OF i_rbkp.
data: begin of i_rseg occurs 0,
belnr LIKE rseg-belnr, "Document Number
gjahr LIKE rseg-gjahr, "Fiscal Year
buzei LIKE rseg-buzei, "Doc.Item
ebeln LIKE rseg-ebeln, "Purchasing Document Number
ebelp LIKE rseg-ebelp, "Item Number
werks LIKE rseg-werks, "Plant
end of i_rseg.
DATA: ws_lines TYPE i.
DATA: BEGIN OF i_ekko OCCURS 0,
ebeln LIKE ekko-ebeln, "Purchasing Document Number
ernam LIKE ekko-ernam, "Name of person who created
ekgrp LIKE ekko-ekgrp, "Purchasing Group
lifre LIKE ekko-lifre, "Different Invoicing Party
END OF i_ekko.
*data: begin of i_ekpo occurs 0,
ebeln like ekpo-ebeln,
werks like ekpo-werks,
end of i_ekpo.
*
DATA: BEGIN OF i_lfa1 OCCURS 0,
lifnr LIKE lfa1-lifnr, "Vendor Number
adrnr LIKE lfa1-adrnr, "Address
name1 LIKE lfa1-name1, "Name 1
name3 LIKE lfa1-name3, "Name 3
brsch LIKE lfa1-brsch, "Industry Key
END OF i_lfa1.
DATA: i_finalx TYPE STANDARD TABLE OF zfs_unplanned.
DATA: i_final LIKE zfs_unplanned OCCURS 0 WITH HEADER LINE.
*data: begin of i_final occurs 0,
lifnr like lfa1-lifnr,
name1 like lfa1-name1,
name3 like lfa1-name3,
brsch like lfa1-brsch,
ebeln like ekko-ebeln,
ernam like ekko-ernam,
ekgrp like ekko-ekgrp,
werks like ekpo-werks,
belnr like rbkp-belnr,
monat like bkpf-monat,
budat like rbkp-budat,
xblnr like rbkp-xblnr,
bldat like rbkp-bldat,
beznk like rbkp-beznk,
waers like rbkp-waers,
end of i_final.
DATA: ok_code LIKE sy-ucomm.
----
Variables for Manipulation
----
DATA : wcl_grid_o_alvgrid TYPE REF TO cl_gui_alv_grid,
wcl_cust_cont TYPE REF TO cl_gui_custom_container.
wcl_container_o_dockcont TYPE REF TO
cl_gui_docking_container.
Define the layout structure
DATA : wa_layout TYPE lvc_s_layo,
Enable variant saving
wa_variant TYPE disvariant, "#EC NEEDED
Field catalogue
i_fieldcat TYPE lvc_t_fcat.
DATA: i_e_toolbar TYPE ui_functions."ALV Toolbar to be excluded
DATA:
ws_c_repid TYPE repid, "To get the prog
" name
ws_c_dynnr TYPE dynnr,
wcl_dock TYPE REF TO cl_gui_docking_container,
"To create instance
ws_c_text TYPE sdydo_text_element,
ws_c_logo TYPE REF TO cl_dd_area,
"Instance for the logo
wcl_docum TYPE REF TO cl_dd_document,
"To create instance
ws_progname TYPE progname,
ws_dynnr TYPE dynnr,
wcl_document TYPE REF TO cl_dd_document.
*
----
C O N S T A N T S *
----
CONSTANTS: c_layout(1) TYPE c VALUE 'A', "All Layouts
c_periv LIKE t001-periv VALUE 'Z1',
c_lifnr_low LIKE lfa1-lifnr VALUE '0003000000',
c_lifnr_high LIKE lfa1-lifnr VALUE '0003999999',
c_exit(4) TYPE c VALUE 'EXIT', " For Exit
c_canc(4) TYPE c VALUE 'CANC', "For Cancel
c_back(4) TYPE c VALUE 'BACK', "For Back
c_weyer TYPE sdydo_key VALUE 'CC1' ,
c_check TYPE c VALUE 'X'.
-
----
INCLUDE ZFRO_UNPLANNED_REPORT_SEL *
----
----
Selection Screen
----
*selection-screen: begin of line.
*selection-screen: position 15.
*selection-screen: comment (55) text-906.
*selection-screen: end of line.
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-900.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN: POSITION 15.
SELECTION-SCREEN: COMMENT (55) text-906.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN:SKIP.
SELECT-OPTIONS: s_lifnr FOR lfa1-lifnr OBLIGATORY,
s_werks FOR t001w-werks OBLIGATORY.
SELECTION-SCREEN: SKIP.
SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME.
SELECTION-SCREEN : BEGIN OF LINE.
PARAMETERS : p_radio1 RADIOBUTTON GROUP grp USER-COMMAND rb.
SELECTION-SCREEN : COMMENT (20) text-901 FOR FIELD p_radio1.
*SELECTION-SCREEN : END OF LINE.
*SELECTION-SCREEN : BEGIN OF LINE.
*selection-screen: position 20.
*SELECTION-SCREEN : COMMENT (5) text-903.
SELECTION-SCREEN: POSITION 28.
SELECT-OPTIONS: s_budat FOR rbkp-budat DEFAULT sy-datum MODIF ID g1.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN : BEGIN OF LINE.
PARAMETERS : p_radio2 RADIOBUTTON GROUP grp.
SELECTION-SCREEN : COMMENT (20) text-902 FOR FIELD p_radio2.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN: POSITION 13.
SELECTION-SCREEN : COMMENT (15) text-904.
SELECTION-SCREEN: POSITION 31.
PARAMETERS: p_monat LIKE bkpf-monat MODIF ID g2.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN: POSITION 13.
SELECTION-SCREEN : COMMENT (15) text-905.
SELECTION-SCREEN: POSITION 31.
PARAMETERS: p_gjahr LIKE bkpf-gjahr MODIF ID g2.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN: END OF BLOCK b2.
SELECTION-SCREEN: SKIP.
SELECT-OPTIONS: s_brsch FOR lfa1-brsch,
s_ekgrp FOR ekko-ekgrp.
SELECTION-SCREEN: END OF BLOCK b1.
----
**********************INITIALIZATION EVENT***************************
----
INITIALIZATION.
PERFORM f0001_initialize_val.
----
**********************At Selction Screen Event************************
----
AT SELECTION-SCREEN ON s_lifnr.
Check if the Vendor Numbers entered in the selection screen are PI
Vendors (i.e)betn. 3000000 and 3999999
IF ( s_lifnr-low LT c_lifnr_low OR
s_lifnr-low GT c_lifnr_high )
OR
( s_lifnr-high LT c_lifnr_low OR
s_lifnr-high GT c_lifnr_high ). "#EC PORTABLE
MESSAGE w000 WITH 'Vendor Numbers should range betn.'
c_lifnr_low
' and '
c_lifnr_high.
ENDIF.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-group1 = 'G2'. "#CCE
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
IF p_radio2 = 'X'.
LOOP AT SCREEN.
IF screen-group1 = 'G1'. "#CCE
screen-input = 0.
MODIFY SCREEN.
ENDIF.
IF screen-group1 = 'G2'.
screen-input = 1.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
-
----
INCLUDE ZFRO_UNPLANNED_CLASS_IMPL *
----
CLASS lcl_recv_grid DEFINITION
----
........ *
----
CLASS lcl_recv_grid DEFINITION.
PUBLIC SECTION.
METHODS :
handle_user_command FOR EVENT user_command
OF cl_gui_alv_grid
IMPORTING e_ucomm ,
handle_before_user_command FOR EVENT before_user_command
OF cl_gui_alv_grid
IMPORTING e_ucomm,
handle_top_of_list
FOR EVENT print_top_of_list OF cl_gui_alv_grid ,
handle_end_of_list
FOR EVENT print_end_of_list OF cl_gui_alv_grid,
*
handle_top_of_page
FOR EVENT print_top_of_page OF cl_gui_alv_grid.
handle_end_of_report
FOR EVENT print_end_of_list OF cl_gui_alv_grid.
ENDCLASS.
----
CLASS lcl_recv_grid IMPLEMENTATION
----
........ *
----
CLASS lcl_recv_grid IMPLEMENTATION.
METHOD handle_user_command.
ENDMETHOD.
METHOD handle_before_user_command.
ENDMETHOD.
METHOD handle_top_of_page.
IF sy-pagno > 1.
WRITE : /1 'User: ', sy-uname, 100 'CCF',
/ 'Date: ', sy-datum.
write: / 'Time: ', sy-uzeit.
ENDIF.
ENDMETHOD.
METHOD handle_top_of_list.
WRITE : /1 'User: ', sy-uname, 100 'CCF',
/ 'Date: ', sy-datum.
write: / 'Time: ', sy-uzeit.
ENDMETHOD.
ENDCLASS.
DATA : wlcl_recv_grid TYPE REF TO lcl_recv_grid .
-
----
INCLUDE ZFRO_UNPLANNED_REPORT_SOS *
----
START-OF-SELECTION.
If Invoice Posting Date is initial or Posting Period & Fiscal Year is
initial, then pop-up a message.
IF s_budat[] IS INITIAL AND
p_monat IS INITIAL AND
p_gjahr IS INITIAL.
MESSAGE i218.
ELSE.
IF p_radio2 = 'X'.
CLEAR: s_budat, ws_begda, ws_endda.
REFRESH s_budat.
Get the Start date & End date of the Posting Period and Fiscal year
entered.
SELECT SINGLE begda endda INTO (ws_begda,ws_endda) FROM t549q
WHERE permo = '00'
AND pabrj = p_gjahr
AND pabrp = p_monat. "#CCE
IF sy-subrc = 0.
Get Doc.No.,posting Date,Fiscal Yr.,Unplanned Del.costs, Ref.Doc.No.,
Doc.Date, Curr.Key, Purch.doc.no., Item Number, Plant for the
selection criteria entered from table RBKP Inner Join RSEG.
SELECT belnr budat gjahr beznk
xblnr bldat waers FROM rbkp
INTO CORRESPONDING FIELDS OF TABLE i_rbkp
WHERE lifnr IN s_lifnr
AND ( lifnr BETWEEN c_lifnr_low and c_lifnr_high )
AND ( budat GE ws_begda
AND budat LE ws_endda )
AND beznk GT '0.00'. "#EC PORTABLE
IF sy-subrc = 0.
PERFORM f0009_get_data_from_rseg.
ENDIF.
ENDIF.
ELSEIF p_radio1 = 'X'.
CLEAR: p_monat, p_gjahr.
SELECT belnr budat gjahr beznk
xblnr bldat waers FROM rbkp
INTO CORRESPONDING FIELDS OF TABLE i_rbkp
WHERE lifnr IN s_lifnr
AND ( lifnr BETWEEN c_lifnr_low and c_lifnr_high )
AND budat IN s_budat
AND beznk GT '0.00'. "#EC PORTABLE
IF sy-subrc = 0.
PERFORM f0009_get_data_from_rseg.
ENDIF.
ENDIF.
CLEAR ws_lines.
DESCRIBE TABLE i_rseg LINES ws_lines.
IF ws_lines > 0.
LOOP AT i_rbkp.
READ TABLE i_rseg WITH KEY belnr = i_rbkp-belnr BINARY SEARCH.
IF sy-subrc = 0.
i_rbkp-ebeln = i_rseg-ebeln.
i_rbkp-ebelp = i_rseg-ebelp.
i_rbkp-werks = i_rseg-werks.
MODIFY i_rbkp.
CLEAR: i_rbkp, i_rseg.
ENDIF.
ENDLOOP.
ENDIF.
SORT i_rbkp BY ebeln.
DELETE ADJACENT DUPLICATES FROM i_rbkp COMPARING ebeln.
DESCRIBE TABLE i_rbkp LINES ws_lines.
IF ws_lines > 0.
Get Purch.Doc.No.,Created By Name, Purch.grp., Diff.Invoicing Party,
Plant from table EKKO Inner Join EKPO.
SELECT ebeln ernam ekgrp lifre FROM ekko
INTO CORRESPONDING FIELDS OF TABLE i_ekko
FOR ALL ENTRIES IN i_rbkp
WHERE ebeln = i_rbkp-ebeln
AND loekz NE 'X' "Check for deletion indicator
AND ekgrp IN s_ekgrp. "#EC PORTABLE
DESCRIBE TABLE i_ekko LINES ws_lines.
IF ws_lines > 0.
*
SORT i_ekko BY ebeln.
*
SELECT bebeln bwerks
INTO CORRESPONDING FIELDS OF TABLE i_ekpo
FROM ekpo AS b
FOR ALL ENTRIES IN i_rbkp
WHERE b~ebeln = i_rbkp-ebeln
AND b~werks IN s_werks.
*
DESCRIBE TABLE i_ekpo LINES ws_lines.
SORT i_ekpo BY ebeln.
*
DELETE ADJACENT DUPLICATES FROM i_ekpo COMPARING ebeln.
*
LOOP AT i_ekko.
*
READ TABLE i_ekpo WITH KEY ebeln = i_ekko-ebeln BINARY SEARCH
*.
IF sy-subrc = 0.
i_ekko-werks = i_ekpo-werks.
MODIFY i_ekko.
CLEAR i_ekko.
ENDIF.
ENDLOOP.
ENDIF.
Get the Vendor Name, Address & Industry Key for the selected Vendors
from table LFA1.
CLEAR ws_lines.
DESCRIBE TABLE i_ekko LINES ws_lines.
IF ws_lines > 0.
SELECT lifnr adrnr name1 name3 brsch
INTO CORRESPONDING FIELDS OF TABLE i_lfa1
FROM lfa1 FOR ALL ENTRIES IN i_ekko
WHERE lifnr = i_ekko-lifre
and lifnr in s_lifnr
and ( lifnr between c_lifnr_low and c_lifnr_high )
AND brsch IN s_brsch. "#CCE
ENDIF.
ENDIF.
SORT i_ekko BY lifre.
SORT i_rbkp BY ebeln.
Populate the final Internal table with necessary data to display as an
ALV report.
LOOP AT i_lfa1.
MOVE-CORRESPONDING i_lfa1 TO i_final.
READ TABLE i_ekko WITH KEY lifre = i_lfa1-lifnr BINARY SEARCH.
IF sy-subrc = 0.
i_final-ebeln = i_ekko-ebeln.
i_final-ernam = i_ekko-ernam.
i_final-ekgrp = i_ekko-ekgrp.
i_final-werks = i_ekko-werks.
READ TABLE i_rbkp WITH KEY ebeln = i_ekko-ebeln BINARY SEARCH.
IF sy-subrc = 0.
i_final-belnr = i_rbkp-belnr.
i_final-budat = i_rbkp-budat.
i_final-xblnr = i_rbkp-xblnr.
i_final-bldat = i_rbkp-bldat.
i_final-beznk = i_rbkp-beznk.
i_final-waers = i_rbkp-waers.
i_final-werks = i_rbkp-werks.
IF p_radio2 = 'X'.
i_final-monat = p_monat.
ELSE.
CLEAR: ws_gjahr,ws_monat.
If the Posting Date is selected in the options, then get the
corresponding dates' Fiscal Period
PERFORM f0008_get_posting_period USING i_rbkp-budat.
i_final-monat = ws_monat.
ENDIF.
ws_beznk = ws_beznk + i_rbkp-beznk.
ENDIF.
ENDIF.
APPEND i_final.
CLEAR: i_final, i_lfa1,i_ekko,i_rbkp,
ws_gjahr,ws_monat.
ENDLOOP.
ENDIF.
CLEAR ws_lines.
DESCRIBE TABLE i_final LINES ws_lines.
IF ws_lines > 0.
If there is data to display, then display the result as an ALV.
CALL SCREEN 9001.
ELSE.
MESSAGE i101.
ENDIF.
&----
*& Form f0009_get_data_from_rseg
&----
Fetch corresponding data from RSEG
----
FORM f0009_get_data_from_rseg.
SORT i_rbkp BY belnr.
CLEAR ws_lines.
DESCRIBE TABLE i_rbkp LINES ws_lines.
if ws_lines > 0.
SELECT belnr gjahr buzei ebeln ebelp werks FROM rseg
INTO CORRESPONDING FIELDS OF TABLE i_rseg
FOR ALL ENTRIES IN i_rbkp
WHERE belnr = i_rbkp-belnr
AND werks IN s_werks
AND gjahr = space
AND buzei = '000001'.
IF sy-subrc = 0.
SORT i_rseg BY belnr.
DELETE ADJACENT DUPLICATES FROM i_rseg COMPARING belnr.
ENDIF.
endif.
ENDFORM. " f0009_get_data_from_rseg
-
----
INCLUDE ZFRO_UNPLANNED_REPORT_EOS *
----
free: i_final,
i_rbkp,
i_rseg,
i_ekko,
i_lfa1.
clear: i_final,
i_rbkp,
i_rseg,
i_ekko,
i_lfa1.
-
Regards
Subramanian
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |