on 06-21-2010 10:02 AM
Hi Experts,
I have a requirment , where when-ever a vendor is created it data is to be captured from table (LFA1).
i.e i just have to fetch the data from LFA1 table , But i an internal table where field name and field value are present.
Like :- Internal table
Component Field Name Field value
Mandt Mandt 020
LIFNR LIFNR 111111111
NAME1 NAME1 Prashant
NAME2 NAME2 Singh
I request you all to please help in developing a logic for the afore said requirment.
Thanks a lot
reagards
Prashant
hi,
use cl_abap_typedescr to get component names and use field symbol to get value.
-
PARAMETERS: p_lifnr type LIFNR.
data: l_wa type lfa1.
FIELD-SYMBOLS: <fs> type any.
DATA: ref_descr TYPE REF TO cl_abap_structdescr,
wa_comp TYPE abap_compdescr.
select SINGLE * from lfa1 into l_wa where lifnr = p_lifnr.
ref_descr ?= cl_abap_typedescr=>describe_by_data( l_wa ).
LOOP AT ref_descr->components INTO wa_comp.
assign COMPONENT wa_comp-name of STRUCTURE l_wa to <fs>.
write:/ wa_comp-name , ' value:', <fs>.
ENDLOOP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Please find below code :
FIELD-SYMBOLS: <fl_table> TYPE table,
<fl_value> TYPE ANY,
<fl_temp> TYPE ANY.
data : it_stru TYPE STANDARD TABLE OF dd03p.
select * from lfa1 into table it_lfa1 where ....some condition.
here u will get some vendors data in it_lfa1 table
assign (it_lfa1) TO <fl_table>.
CREATE DATA dref LIKE LINE OF <fl_table>.
ASSIGN dref->* TO <fl_temp>.
*Get field details of table
CALL FUNCTION 'DDIF_TABL_GET'
EXPORTING
name = ufl_str
TABLES
dd03p_tab = it_stru.
**************U will get all field names in table it_stru
LOOP AT <fl_table> ASSIGNING <fl_temp>.
LOOP AT it_stru INTO wa_stru.
ASSIGN COMPONENT wa_stru-fieldname OF STRUCTURE <fl_temp> TO
<fl_value>.
wa_output-feildname_name = wa_stru-fieldname.
wa_output-feildname_value = <fl_temp>.
append wa_output to it_output.
endloop.
endloop.
finally in it_output u will get field name and field value. Declare it's structure with 2 fields field_name (char50) field_value(char200).
Hope it works.....
Regards,
Yogesh.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
Please elaborate your question . Its not clear ,
If you need to fetch some fields form
LFA1 then
data : itab_lfa1 type table of LFA1.
SELECT *
from lfa1
INto TABLE iTAB_lfa1
WHERE SOME CONDITIONS
Hope this is clear.
Regards,
Uma Dave
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Both ,
Thanks for giving consideration to my query , but thats not my requirment.
But i want to have logic where i can have all the fields of LFA1 table and there valuue like this:-
lets say i have internal table with two coloumns
Field name(LFA1) value (LFA1)
Mandt 010
Lifnr 11111111
Now to achive this fuctionality i have used FM "DDIF_FIELDINFO_GET", which is fetching all the field of
Lfa1 into table ,and with the select query i can fetch the value of the fields .
I am not able to get the logic to 1:1 filling of these field name and thier value in internal table , I have explained above.
Please help me over the same.
Regards
Prashant
hi prashant,
wat i understood according to tat
SELECT *
from lfa1
INto TABLE i_lfa1
WHERE erdat = sy-datum.
try something like tat ..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.