‎2009 Mar 25 10:43 AM
hi,
when user enters the any fieldname from MARC table related , the only that field descrption
should come in WE variable in selection screen.
if no field existing in MARC , then error message will come..
can somebody give the logic.
selection-screen begin of line.
parameters:p_selec1 like dd02l-tabname ,
we(200).
selection-screen end of line.
‎2009 Mar 25 11:01 AM
Hi,
Check this.
TABLES:dd03l.
PARAMETERS:p_fname TYPE fieldname.
AT SELECTION-SCREEN.
SELECT SINGLE * FROM dd03l WHERE tabname = 'MARC' AND fieldname = p_fname.
IF sy-subrc NE 0.
MESSAGE E016(rp) WITH 'Enter Proper Field'.
ENDIF.
‎2009 Mar 25 11:03 AM
You can set the values in AT SELECTION-SCREEN EVENT.
If you press enter the vent will be execute and values will be changed
Or use SY-ucomm = 'ONLI' -->F8
parameters:p_selec1 like dd02l-tabname ,
we(200).
selection-screen end of line.
at selection-screen.
Select query. " If you press enter
IF SY-SUBRC NE 0. " No records present
we = 'ERROR'
ENDIF.Regards,
Gurpreet
‎2009 Mar 26 10:19 AM
use thuis.
AT SELECTION-SCREEN on parametere.
SELECT SINGLE field FROM dd03l WHERE tabname = 'MARC' AND fieldname = p_fname.
IF sy-subrc NE 0.
MESSAGE 'No record found '. type 'E'.
ENDIF
Regards
‎2009 Mar 26 6:33 PM
HI,
Try this way...
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS:p_selec1 LIKE dd03l-fieldname ,
we(200).
SELECTION-SCREEN END OF LINE.
AT SELECTION-SCREEN .
* Write the logic to fetch the data into we varaible if we is inital show the error message
WE = 'Test'.
‎2009 Mar 27 10:41 AM
Hi, try this one.
TABLES : dd03l.
DATA : v_fieldname type fieldname.
DATA : v_ddtext type as4text.
PARAMETERS : p_fname TYPE fieldname user-command com .
parameters : WE(200) type c.
AT SELECTION-SCREEN.
SELECT SINGLE fieldname FROM dd03l
into v_fieldname
WHERE tabname = 'MARC' AND fieldname = p_fname.
IF sy-subrc NE 0.
MESSAGE E000(sd) WITH 'Enter Proper Field'.
else.
select single ddtext from DD03t
into v_ddtext
where tabname = 'MARC'
and fieldname = p_fname
and ddlanguage = 'EN'.
endif.
at selection-screen output.
we = v_ddtext.
‎2009 Mar 27 10:43 AM
‎2009 Apr 02 11:03 AM
AT SELECTION-SCREEN on p_field1.
SELECT SINGLE field1 FROM dd03l
INTO l_field1
WHERE tabname = 'MARC' AND fieldname = p_field1.
IF sy-subrc NE 0.
Error Message*
ENDIF.
Regards,
Joan
‎2009 Apr 02 2:18 PM
HI,
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: p_matnr TYPE MARC-MATNR OBLIGATORY.
SELECTION-SCREEN END OF LINE.
AT SELECTION-SCREEN ON p_matnr.
DATA:l_aaaaa TYPE MARC-MATNR .
CLEAR l_aaaa.
SELECT SINGLE MATNR
INTO l_werks
FROM MARC
WHERE MARC = p_matnr
IF sy-subrc NE 0.
MESSAGE e208(00) WITH 'E03: Invalid entry'(e03).
ENDIF. " IF sy-subrc NE 0.
‎2009 Apr 02 2:37 PM
Hi!
Try this code. I hope it can solve ur req.
TABLES:dd03l.
PARAMETERS:p_fname TYPE fieldname.
data : lv_field type char300.
AT SELECTION-SCREEN.
SELECT SINGLE * FROM dd03l into lv_field
WHERE tabname = 'MARC'
AND fieldname = p_fname.
IF sy-subrc NE 0.
MESSAGE E001(0) WITH 'Enter Proper Field'.
ELSE.
MESSAGE S001(0) WITH 'Field exists'.
ENDIF.
‎2009 Apr 02 2:41 PM
Hi Nayar,
see the below examples and write as wish
Dynamic where clause
You can use an internal table to build a dynamic where clause:
data: where_tab(30) occurs 1 with header line,
where_clause(30) type c.
* Build the where clause. Will look like this when finished
* WHERE ZAFSTMD02 = 'X' AND rbusa = '5145'
* With a constant, result: ZAFSTMD01 = 'X'
concatenate 'ZAFSTMD' zcostcheck-zmaaned ' = ''X''' into where_clause.
* Append to internal table where_tab
append where_clause to where_tab.
* With a variable, result: AND rbusa = '5145'
concatenate 'AND rbusa = ' '''' i_tab-zgsber ''''
append where_clause to where_tab.
* Select
select * from zcostfreq
where (where_tab).
endselect.
Note that you can combine static and dynamic where clauses:
select * from zcostfreq
where bukrs = '2021' AND
(where_tab).
endselect.
Using a dynamic table name
This report prints the number og entries in a table. The table name is specified by a parameter.
data:
l_count type i.
parameters:
p_tab type tabname.
start-of-selection.
select count(*) from (p_tab) into l_count.
write: / 'Number of entries in table ', p_tab, l_count.
Dynamic retrieval and writing of data
In this example, data is retrieved from the table selected on the selection screen, and the contents of the table is written to the screen.
DATA:
* Create variable that can contain referecene to any data
dataref TYPE REF TO data.
FIELD-SYMBOLS:
<row> TYPE ANY,
<component> TYPE ANY.
PARAMETERS:
p_tab TYPE tabname.
START-OF-SELECTION.
* Create a workarea for the tabel selected on the selection screen
CREATE DATA dataref TYPE (p_tab).
* The variable dataref cannot be accessed directly, so a field symbol is
* used
ASSIGN dataref->* TO <row>.
SELECT *
FROM (p_tab) UP TO 10 ROWS
INTO <row>.
NEW-LINE.
DO.
* Write all the fields in the record
ASSIGN COMPONENT sy-index
OF STRUCTURE <row>
TO <component>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
WRITE <component>.
ENDDO.
ENDSELECT.
Dynamic SELECT
TYPES:
BEGIN OF st_bseg,
bukrs LIKE bseg-bukrs,
belnr LIKE bseg-belnr,
dmbtr LIKE bseg-dmbtr,
END OF st_bseg.
DATA:
sel_list TYPE STANDARD TABLE OF edpline,
li_bseg TYPE STANDARD TABLE OF st_bseg,
l_bseg TYPE st_bseg.
START-OF-SELECTION.
APPEND 'bukrs belnr dmbtr' TO sel_list.
SELECT (sel_list)
FROM bseg UP TO 100 ROWS
INTO TABLE li_bseg.
LOOP AT li_bseg INTO l_bseg.
WRITE : / l_bseg-bukrs, l_bseg-belnr, l_bseg-dmbtr.
ENDLOOP.
regards,
Prabhudas
‎2009 Apr 02 2:43 PM
Hi ,
Try this...
DATA: D_TYPE,
D_FIELD(35).
DATA: D_TEST TYPE P.
FIELD-SYMBOLS: <F>.
D_FIELD = 'D_TEST'.
D_TYPE = 'P'.
ASSIGN (D_FIELD) TO <F> TYPE D_TYPE.
Additionally you can use the option DECIMALS of the ASSIGN statement if your type is 'P'. You can even change the type at runtime of previously assigned field symbol like
ASSIGN <F> TO <F> TYPE 'C'.
One more thing for dynamic programing. With the following coding you can access every DDIC table with the key you want:
SELECT SINGLE * FROM (DF_TNAME) INTO S_TMP WHERE (IF_KEY).
if sy-subrc ne 0.
message 'Wrong input' type 'E'.
endif.
Regards,
Prabhudas