cancel
Showing results for 
Search instead for 
Did you mean: 

Developemnt logic for table entries

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (4)

Answers (4)

0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

hi prashant,

wat i understood according to tat

SELECT *

from lfa1

INto TABLE i_lfa1

WHERE erdat = sy-datum.

try something like tat ..