‎2006 Sep 01 12:54 PM
Hi,
can any one help me how to write dyanamic READ statement
If we do not know the name of a component until runtime, then how we can use the expression WITH TABLE KEY ... to specify it keys dynamically .
please send some sample code to illustrate
thanks...
‎2006 Sep 01 12:56 PM
Hai Bobby,
Do you want to pass the fields dynamically ? Then use the statement
read table it_tab with key (fieldname) = 'VALUE'.
‎2006 Sep 01 12:56 PM
Hai Bobby,
Do you want to pass the fields dynamically ? Then use the statement
read table it_tab with key (fieldname) = 'VALUE'.
‎2006 Sep 01 1:03 PM
hi,
try:
DATA key1(72) VALUE 'BUKRS'.
...
read table itab with key (key1) = ztab-bukrs.
Message was edited by: Andreas Mann
‎2006 Sep 01 1:12 PM
A)
DATA: T LIKE STANDARD TABLE OF BKPF WITH HEADER LINE.
DATA: FIELD1(10),
FIELD2(10).
FIELD1 = .....
FIELD2 = .....
READ TABLE T WITH TABLE KEY (FIELD1) = <VALUE>
(FIELD2) = <VALUE>.
B)
DATA: T LIKE STANDARD TABLE OF BKPF WITH HEADER LINE WITH NON-UNIQUE KEY BUKRS BELNR.
DATA: FIELD1(10),
FIELD2(10).
FIELD1 = .....
FIELD2 = .....
READ TABLE T WITH TABLE KEY (FIELD1) = <VALUE>
(FIELD2) = <VALUE>.
Max
‎2006 Sep 04 6:22 AM
hi,
but can you tell me how to pass whole key with fields & value
thanks
‎2006 Sep 04 7:01 AM
Hi,
1.You can fill the fieldname statically or dynamically using cl_abap_*type classes.
2. you can fill the fieldvalue using ASSIGN ...COMPONENT
variant like this..
field-symbols: <lv_field_value> type any.
ASSIGN COMPONENT fieldname
OF STRUCTURE ls_strucure_name TO <lv_field_value>.
If it is assigned sy-subrc will be 0.
Regards,
Suresh
‎2006 Sep 04 9:29 AM
Hi,
could you please tell me how to pass the key fields and the value as in the below read statement in brackets dyanamically because I have senario where different fields are being populated for different cases.
read table itab with key ( matnr = jtab-matnr
werks = jtab-werks )
thanks