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

FORMs STRUCTURE option

Former Member
0 Likes
309

I understood that, in order to manipulate fields from an internal table or record passed as a parameter to a given form, you have to include STRUCTURE [table / struct name]. I wonder how would it be possible to have a program that decides, dynamically, amongst several possible table parameters - if we indeed have to have the STRUCTURE hard-coded, would such a thing be possible ?

Example:

FORM TEST      TABLES P_ITAB STRUCTURE BSEG	
	                USING P_REC STRUCTURE WS_REC.

In the above excerpt of code, it is known beforehand that the table is of the BSEG type. Imagining a scenario where I would only have this information at run time, would it be possible to determine the structure of the table ?

Thanks

Avraham

1 ACCEPTED SOLUTION
Read only

franois_henrotte
Active Contributor
0 Likes
290

if you don't have to know field names, you can use this simple solution:


FORM TEST      TABLES P_ITAB
	                USING P_REC STRUCTURE WS_REC.

FIELD-SYMBOLS: <itab> TYPE ANY.

LOOP AT p_itab ASSIGNING <itab>.
  MOVE-CORRESPONDING <itab> TO p_rec.
ENDLOOP.

ENDFORM.

you can still assign a field of <itab> but you have to do it for each field with ASSIGN COMPONENT

if you have a lot of named fields to use then you can map the input parameter into a local table with the structure you need

1 REPLY 1
Read only

franois_henrotte
Active Contributor
0 Likes
291

if you don't have to know field names, you can use this simple solution:


FORM TEST      TABLES P_ITAB
	                USING P_REC STRUCTURE WS_REC.

FIELD-SYMBOLS: <itab> TYPE ANY.

LOOP AT p_itab ASSIGNING <itab>.
  MOVE-CORRESPONDING <itab> TO p_rec.
ENDLOOP.

ENDFORM.

you can still assign a field of <itab> but you have to do it for each field with ASSIGN COMPONENT

if you have a lot of named fields to use then you can map the input parameter into a local table with the structure you need