Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Run time column names as parameters

Former Member
0 Likes
443

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
398

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.

1 REPLY 1
Read only

Former Member
0 Likes
399

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