‎2008 Jul 18 8:00 AM
Hi,
I need the simple coding for data retrive using any database table, but validations (2 0r 3) are must. Cany anyone help me in this issue?
Thankyou.
‎2008 Jul 18 8:03 AM
Hi,
use a simple query like ...
data: it_table type standard table of <your table name> .
Select * from <your table name> into it_table where <match any condition here>.
‎2008 Jul 18 8:03 AM
hey,
what you actually need? i mean which table and what fields? i really dint get u.
‎2008 Jul 18 8:04 AM
Very simple sample code:
report ztest.
tables: mara.
select-options: s_matnr for mara-matnr,
s_matkl for mara-matkl.
start-of-selection.
select * from mara where matnr in s_matnr and matkl in s_matkl. "And the list goes on...
various handling logic goes here
endselect.
‎2008 Jul 18 8:04 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. :
* Development Class :
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* 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 'LOGO1' ,
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 'COMPANY NAME',
/ 'Date: ', sy-datum.
write: / 'Time: ', sy-uzeit.
ENDIF.
ENDMETHOD.
METHOD handle_top_of_list.
WRITE : /1 'User: ', sy-uname, 100 'COMPANY NAME',
/ '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 b~ebeln b~werks
* 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.
--------------------------------------------------------------------------------
‎2008 Jul 18 8:06 AM
Hi Usha.
This is a simple report.
REPORT ZGLACC message-id zrmes no standard page heading line-size 200.
TABLES:skb1,bkpf,bseg.
TYPES: BEGIN OF i_skb1,
bukrs TYPE skb1-bukrs,
saknr TYPE skb1-saknr,
xgkon TYPE skb1-xgkon,
xkres TYPE skb1-xkres,
END OF i_skb1.
TYPES: BEGIN OF i_bkpf,
bukrs TYPE bkpf-bukrs,
belnr TYPE bkpf-belnr,
gjahr type bkpf-gjahr,
bldat TYPE bkpf-bldat,
budat TYPE bkpf-budat,
bktxt TYPE bkpf-bktxt,
END OF i_bkpf.
TYPES: BEGIN OF i_bseg,
bukrs TYPE bseg-bukrs,
belnr TYPE bseg-belnr,
gjahr type bseg-gjahr,
augbl TYPE bseg-augbl,
augdt TYPE bseg-augdt,
shkzg TYPE bseg-shkzg,
wrbtr TYPE bseg-wrbtr,
hkont type bseg-hkont,
sgtxt type bseg-sgtxt,
END OF i_bseg.
TYPES: BEGIN OF i_final,
saknr TYPE skb1-saknr,
sgtxt TYPE bseg-sgtxt,
bldat TYPE bkpf-bldat,
budat TYPE bkpf-budat,
debit TYPE bseg-wrbtr,
credit TYPE bseg-wrbtr,
belnr type bkpf-belnr,
augbl TYPE bseg-augbl,
augdt TYPE bseg-augdt,
bktxt TYPE bkpf-bktxt,
END OF i_final.
DATA: it_final TYPE TABLE OF i_final INITIAL SIZE 10,
wa_final TYPE i_final.
DATA: it_skb1 TYPE TABLE OF i_skb1 INITIAL SIZE 10,
wa_skb1 TYPE i_skb1.
DATA: it_bkpf TYPE TABLE OF i_bkpf INITIAL SIZE 10,
wa_bkpf TYPE i_bkpf.
DATA: it_bseg TYPE TABLE OF i_bseg INITIAL SIZE 10,
wa_bseg TYPE i_bseg.
DATA: date1(10),
date2(10),
number(10),
ccode(4),
v_xgkon type skb1-xgkon.
DATA: sum_debit type bseg-wrbtr,
sum_credit type bseg-wrbtr.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE tit1.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) text-001 FOR FIELD no.
PARAMETERS:no TYPE bseg-hkont.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) text-005 FOR FIELD code.
PARAMETERS:code TYPE bseg-bukrs.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN COMMENT 1(13) text-002.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(10) text-003 FOR FIELD d1.
PARAMETERS:d1 TYPE bkpf-budat.
SELECTION-SCREEN COMMENT 30(10) text-004 FOR FIELD d2.
PARAMETERS:d2 TYPE bkpf-budat.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK blk1.
INITIALIZATION.
tit1 = 'SELECTION-CRITERIA'.
AT SELECTION-SCREEN.
select single xgkon from skb1 into v_xgkon where saknr = no
and bukrs = code.
if v_xgkon eq ' '.
MESSAGE e002(zrmes) WITH no.
endif.
IF d1 IS INITIAL
OR d2 IS INITIAL.
MESSAGE w001(zrmes).
ELSE.
number = no.
date1 = d1.
date2 = d2.
ccode = code.
ENDIF.
TOP-OF-PAGE.
format intensified off.
write:/1(186) sy-uline.
WRITE:/1 sy-vline,
2 'GL.ACC.NO' color 6,
13 sy-vline,
14 'DESCRIPTION' color 6,
65 sy-vline,
66 'DOC.DATE' color 6,
77 sy-vline,
78 'POST.DATE' color 6,
89 sy-vline,
90 'DEBIT' color 6,
106 sy-vline,
107 'CREDIT' color 6,
123 sy-vline,
124 'INVOICE.NO' color 6,
135 sy-vline,
136 'CL.DOC.NO' color 6,
147 sy-vline,
148 'CL.DOC.DATE' color 6,
159 sy-vline,
160 'DOCUMENT.HEADER.TEXT' color 6,
186 sy-vline.
write:/1(186) sy-uline.
START-OF-SELECTION.
SELECT bukrs
belnr
gjahr
augbl
augdt
shkzg
wrbtr
hkont
sgtxt
FROM bseg
INTO TABLE it_bseg
WHERE bukrs = code
AND hkont = no.
Rewards Points, if it is useful.
Regards,
Sharmista.
‎2008 Jul 18 8:08 AM
for validation on selection screen, do something like:
AT SELECTION-SCREEN:
if s_kunnr is not initial.
select single kunnr
from kna1
into lw_kunnr
where kunnr in s_kunnr.
if sy-subrc <> 0 and lw_kunnr is initial.
message ............
endif. " If sy-subrc <> 0 AND
endif.
With luck,
Pritam.
‎2008 Jul 18 8:09 AM
Hi,
check the code
Data declaration---------------------------------------------------*
" Table declaration----
TABLES:
sflight. " Flight
" Selection screen elements----
SELECTION-SCREEN BEGIN OF BLOCK s_blk1 WITH FRAME TITLE text-000.
SELECT-OPTIONS:
s_carrid FOR sflight-carrid,
s_connid FOR sflight-connid.
SELECTION-SCREEN END OF BLOCK s_blk1.
"----
Field string to hold flight data
"----
DATA:
BEGIN OF fs_sflight,
carrid TYPE sflight-carrid, " Airline Code
connid TYPE sflight-connid, " Flight Connection Number
fldate TYPE sflight-fldate, " Flight date
seatsmax TYPE sflight-seatsmax, " Maximum seats
seatsocc TYPE sflight-seatsocc, " Occupied seats
END OF fs_sflight.
"----
Internal table to hold flight data
"----
DATA:
t_sflight LIKE
STANDARD TABLE
OF fs_sflight.
"----
Field string to hold airline code of sflight
"----
DATA:
BEGIN OF fs_carrid,
carrid TYPE sflight-carrid, " Airline Code
connid TYPE sflight-connid,
END OF fs_carrid.
"----
Internal table to hold airline code of sflight
"----
DATA:
t_carrid LIKE
STANDARD TABLE
OF fs_carrid.
"----
Work variables
"----
DATA:
min_carrid TYPE sflight-carrid,
max_carrid TYPE sflight-carrid.
"----
INITIALIZATION
"----
INITIALIZATION.
PERFORM value_initial.
"----
AT SELECTION-SCREEN ON s_carrid Event
"----
AT SELECTION-SCREEN ON s_carrid.
PERFORM carrid_validate.
"----
AT SELECTION-SCREEN ON s_carrid Event
"----
AT SELECTION-SCREEN ON s_connid.
PERFORM connid_validate.
"----
TOP-OF-PAGE Event
"----
TOP-OF-PAGE.
PERFORM heading.
"----
START-OF-SELECTION Event
"----
START-OF-SELECTION.
PERFORM get_data_sflight.
"----
END-OF-SELECTION Event
"----
END-OF-SELECTION.
PERFORM display_data_sflight.
&----
*& Form value_initial
&----
Subroutine to initialize the low and high value of select option
----
--> p1 N/A
<-- p2 N/A
----
FORM value_initial .
SELECT MIN( carrid ) MAX( carrid )
FROM sflight
INTO (min_carrid, max_carrid).
MOVE min_carrid TO s_carrid-low.
MOVE max_carrid TO s_carrid-high.
APPEND s_carrid.
ENDFORM. " value_initial
&----
*& Form carrid_validate
&----
Subroutine to validate the low and high value of select option
----
--> p1 N/A
<-- p2 N/A
----
FORM carrid_validate .
DATA:
lw_carrid TYPE sflight-carrid.
SELECT SINGLE carrid " Airline Code
FROM sflight
INTO lw_carrid
WHERE carrid EQ s_carrid-low.
IF sy-subrc NE 0.
MESSAGE e031(db6)
WITH ' Low value of the range'(006) s_carrid-low.
ENDIF. " IF sy-subrc NE 0.
CLEAR lw_carrid .
SELECT SINGLE carrid " Airline Code
FROM sflight
INTO lw_carrid
WHERE carrid EQ s_carrid-high.
IF sy-subrc NE 0.
MESSAGE e031(db6)
WITH ' High value of the range'(007) s_carrid-high.
ENDIF. " IF sy-subrc NE 0.
CLEAR lw_carrid .
ENDFORM. " carrid_validate
"----
End of code
*"----
&----
*& Form connid_validate
&----
text
----
--> p1 text
<-- p2 text
----
form connid_validate .
DATA:
lw_connid TYPE sflight-connid.
SELECT SINGLE connid " Airline Code
FROM sflight
INTO lw_connid
WHERE connid EQ s_connid-low.
IF sy-subrc NE 0.
MESSAGE e031(db6)
WITH ' Low value of the range'(006) s_connid-low.
ENDIF. " IF sy-subrc NE 0.
CLEAR lw_connid .
SELECT SINGLE connid " Airline Code
FROM sflight
INTO lw_connid
WHERE connid EQ s_connid-high.
IF sy-subrc NE 0.
MESSAGE e031(db6)
WITH ' High value of the range'(007) s_connid-high.
ENDIF. " IF sy-subrc NE 0.
CLEAR lw_connid .
endform. " connid_validate
&----
*& Form heading
&----
Subroutine to create page heading
----
--> p1 N/A
<-- p2 N/A
----
FORM heading .
WRITE:
/2 'CARRID'(001), " Airline Code
10 'CONNID'(002), " Flight Connection Number
20 'FLDATE'(003), " Flight date
32 'SEATSMAX'(004), " Maximum seats
42 'SEATSOCC'(005). " Occupied seats
ULINE /2(50).
ENDFORM. " Heading
&----
*& Form get_data_sflight
&----
subroutine to extract data from sflight
----
--> p1 N/A
<-- p2 N/A
----
FORM get_data_sflight .
SELECT carrid " Airline Code
connid " Flight Connection Number
fldate " Flight date
seatsmax " Maximum seats
seatsocc " Occupied seats
INTO TABLE t_sflight
FROM sflight
WHERE carrid IN s_carrid.
ENDFORM. " Get_data_sflight
&----
*& Form display_data_sflight
&----
subroutine to display extracted data from sflight
----
--> p1 N/A
<-- p2 N/A
----
FORM display_data_sflight .
LOOP AT t_sflight INTO fs_sflight.
AT NEW carrid.
SKIP.
ENDAT. " AT NEW carrid.
WRITE:
/5 fs_sflight-carrid, " Airline Code
11 fs_sflight-connid, " Flight Connection Number
18 fs_sflight-fldate, " Flight date
28 fs_sflight-seatsmax, " Maximum seats
38 fs_sflight-seatsocc. " Occupied seats
ENDLOOP. " LOOP AT t_sbook INTO.......
ENDFORM. " Display_data_sflight
*
Regards,
anirban
‎2008 Jul 18 8:10 AM
Hi Usha,
The question is a little bit ambigous.
Anyways Proceed this way
----
Includes
----
*Global Declarations
INCLUDE ztop.
*Subroutines
INCLUDE zsubr.
----
Initialization
----
INITIALIZATION.
PERFORM initialize_plant.
----
AT SELECTION SCREEN
----
AT SELECTION-SCREEN.
----
Validation
----
PERFORM authority_check.
PERFORM date_check.
----
START OF SELECTION
----
START-OF-SELECTION.
PERFORM fetch_data.
PERFORM fill_output.
PERFORM write_applserv.
----
*END-OF-SELECTION
----
END-OF-SELECTION.
PERFORM output_display.
Where inFORM authority_check.
IF pa_werks NE <customized>
*Select plant as <customized>
MESSAGE e809().
ENDIF.
Checking Whether the User has authorization for the Plant.
AUTHORITY-CHECK OBJECT ' PROD' ID 'WERKS' FIELD pa_werks.
IF sy-subrc <> 0.
NO AUTHORIZATION FOR PLANT.
MESSAGE e16.
ENDIF.
FORM date_check.
CALL FUNCTION 'LAST_DAY_OF_MONTHS'
EXPORTING
day_in = pa_date
IMPORTING
last_day_of_month = g_dateto1.
IF pa_date <> g_dateto1.
Please enter the last day of the month
MESSAGE e866.
ENDIF.
ENDFORM.
ENDFORM.
Generally you dont fetch data in at selection screen do it for start-of-selection.
check a simple code for that.
-> Fetch Sales Organisation
CLEAR : wf_vkorg.
SELECT SINGLE vkorg
INTO wf_vkorg
FROM tvkwz
WHERE werks = pa_werks.
IF sy-subrc EQ 0.
Do Nothing
ENDIF.
You can check the follow of events and not necessary you need to put the validation as mentioned they are requirement specific.
Forms are given for the Perform used in At selection screen event.
Reward points if useful.
Mohinder Singh Chauhan
‎2008 Jul 18 8:22 AM
Hi,
Validate the fields using At selection-screen event .
Here is one small example how to validate screen fields data.
tables:
spfli.
select-options:
s_carrid for spfli-carrid.
data:
begin of fs_spfli,
carrid like spfli-carrid,
connid like spfli-connid,
end of fs_spfli.
data:
t_spfli like standard table of fs_spfli.
data:
w_carrid like spfli-carrid.
at selection-screen.
if s_carrid is initial.
message 'Please enter carrier id' type 'E'.
else.
select single carrid
from spfli
into w_carrid
where carrid in s_carrid..
if sy-subrc ne 0.
message 'No carriers found' type 'E'.
endif.
endif.
start-of-selection.
select carrid
connid
from spfli
into table t_spfli
where carrid in s_carrid.
loop at t_spfli into fs_spfli.
write :/ fs_spfli-carrid,
fs_spfli-connid.
endloop.Regards,
Rajitha.