2011 Mar 14 10:26 AM
Hi,
Using dynamic fieldlist based on certain conditions in SELECT statement.
data: fdlist TYPE STANDARD TABLE OF line WITH HEADER LINE.
create fieldlist as which can have n no of fields
concatenate FDLIST wfieldcat-fieldname into fDList.
Now want to select from table and want to modify only those fields of internal table which are getting modified.
loop at itab into wa_itab.
SELECT single (fdlist) from BSEG into
corresponding fields of itab
WHERE BELNR = wa_itab-BELNR.
modify itab from wa_itab transporting (fdlist)
where belnr = wa_itab_BELNR.
endloop.
this loop is working fine for one field but in case of more than one gives error. The dynamic works fine if no of fields are specified as (f1) (f2) (f3).
how to determine dynamically the no of fields. and specify.How can I assign vlues dynamically to fields to transporting statement.
Thanks
pa
Hi,
Using dynamic fieldlist based on certain conditions in SELECT statement.
data: fdlist TYPE STANDARD TABLE OF line WITH HEADER LINE.
create fieldlist as which can have n no of fields
concatenate FDLIST wfieldcat-fieldname into fDList.
Now want to select from table and want to modify only those fields of internal table which are getting modified.
loop at itab into wa_itab.
SELECT single (fdlist) from BSEG into
corresponding fields of itab
WHERE BELNR = wa_itab-BELNR.
modify itab from wa_itab transporting (fdlist)
where belnr = wa_itab_BELNR.
endloop.
this loop is working fine for one field but in case of more than one gives error. The dynamic works fine if no of fields are specified as (f1) (f2) (f3).
how to determine dynamically the no of fields. and specify.How can I assign vlues dynamically to fields to transporting statement.
Thanks
pa
2011 Mar 14 11:29 AM
Hi Anya,
I don't know how to specifiy a list of filed in istruction "modify... transporting".
Anyway, you could use:
modify itab from wa_itab transporting (FIELD_1) (FIELD_2) (FIELD_3) (FIELD_4).... (FIELD_N),
if you have for example only 2 fields to update, you must set the value of field_1 and field_2. field_3 to field_n will be not considered from modify instruction.
If you have more than n fields to update, you could use a do/enddo until all your fields are updated.
Hope this could be helpful.
Regards
Andrea