cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

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

0 Likes
View Entire Topic
Former Member
0 Likes

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.