2008 Jan 10 10:44 PM
Hi SDN,
I am trying to use a FORM/ENDFORM which can work for many internal tables in my project except that a couple of field (table columns) names differ. In other words, just for two assignment statements I may have to repeat rest of the code, unless there is a way to 'reference' these fields.
Is there a way to pass the field names as a parameter to the FORM? Can someone give me an example if that is possible. I looked at the FIELD SYMBOL but don't know how to use it in a FORM.
Thanks for the help.
Saf.
2008 Jan 11 10:08 PM
FM DDIF_NAMETAB_GET retruns a table of field names.
Sample code follows (hope it helps!)
call function 'DDIF_NAMETAB_GET'
exporting
tabname = 'Z213'
tables
dfies_tab = lta_dfies
exceptions
not_found = 1
others = 2.
if sy-subrc <> 0.
message e007 with 'syserr bld bkpf fields.'.
endif."subrc
loop at lta_dfies assigning <i>.
append <i>-fieldname to lta_bkpf_fl.
endloop."dfies
select (lta_bkpf_fl)
from bkpf
into table lth_vbkpf
where
bukrs = p_bukrs
and bstat = space " normal documant
and blart = 'WE'
and gjahr = p_gjahr
and monat in so_monat
and budat in so_budat
and waers in so_waers
order by belnr.
if sy-subrc <> 0.
message i008 with 'No BKPF data found for selection'.
stop.
endif."subrc.
Best,
Jim
Hi SDN,
I am trying to use a FORM/ENDFORM which can work for many internal tables in my project except that a couple of field (table columns) names differ. In other words, just for two assignment statements I may have to repeat rest of the code, unless there is a way to 'reference' these fields.
Is there a way to pass the field names as a parameter to the FORM? Can someone give me an example if that is possible. I looked at the FIELD SYMBOL but don't know how to use it in a FORM.
Thanks for the help.
Saf.
2008 Jan 11 10:08 PM
FM DDIF_NAMETAB_GET retruns a table of field names.
Sample code follows (hope it helps!)
call function 'DDIF_NAMETAB_GET'
exporting
tabname = 'Z213'
tables
dfies_tab = lta_dfies
exceptions
not_found = 1
others = 2.
if sy-subrc <> 0.
message e007 with 'syserr bld bkpf fields.'.
endif."subrc
loop at lta_dfies assigning <i>.
append <i>-fieldname to lta_bkpf_fl.
endloop."dfies
select (lta_bkpf_fl)
from bkpf
into table lth_vbkpf
where
bukrs = p_bukrs
and bstat = space " normal documant
and blart = 'WE'
and gjahr = p_gjahr
and monat in so_monat
and budat in so_budat
and waers in so_waers
order by belnr.
if sy-subrc <> 0.
message i008 with 'No BKPF data found for selection'.
stop.
endif."subrc.
Best,
Jim