‎2011 Dec 05 10:53 AM
Dear all,
i have a query regarding smart forms.i want to pass the internal table to smart form.i have written the code like this
TYPES:BEGIN OF TY_MARA, " Local structure
MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
END OF TY_MARA.
DATA:E_MARA TYPE TY_MARA. " work area
DATA:TS_MARA TYPE STANDARD TABLE OF TY_MARA. "internal table
SELECT MATNR
ERSDA
ERNAM INTO TABLE TS_MARA FROM MARA.when i use the local structure its showing error like @8O@ Form Interface Only table types may be used as the reference type for a table parameter.
if it's a dictionary structure it's working fine.But in case of local structure its not working .in some threads ,they mentioned that we should use only dictionary structure.is that right ?
‎2011 Dec 05 11:08 AM
‎2011 Dec 05 12:54 PM
‎2011 Dec 05 1:02 PM
Hi Naresh,
Yes you need to use a dictionary structure in the form interface. If it's a local structure that means the scope of that TYPE only exists within the program and is not available outside of that program (including programs trying to call the smartform interface).
Regards,
Ryan Crosby
‎2011 Dec 05 1:08 PM
Hi,
Can't we create smartforms using local structure which is defined in Driver program?
With regards
Naresh
‎2011 Dec 05 1:21 PM
Hi,
No, you need a type defined in the global dictionary so the system can generate the FM to be called from the driver program and you cannot generate a FM with a parameter that is only locally defined. The only possible way to do that would be if it were something like TYPE REF TO DATA and the calling program passed it in as a data reference (not worth the effort I would think).
Regards,
Ryan Crosby
‎2011 Dec 05 2:03 PM
Hello,
Actually Ryan's idea is correct one, don't know why he dropped it. You would require the following:
1) in program create local table type
TYPES:BEGIN OF TY_MARA, " Local structure
MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
END OF TY_MARA.
TYPES: TT_MARA TYPE TABLE OF TY_MARA.
2) store your fetched data under data reference
SELECT MATNR
ERSDA
ERNAM INTO TABLE TS_MARA FROM MARA.
DATA: LR_MARA TYPE REF TO DATA.
GET REFERENCE OF TS_MARA INTO LR_MARA.
3) in smartform interface type parameter IT_MARA TYPE REF TO DATA
4) in smartform Local Types tab create your local type
TYPES:BEGIN OF TY_MARA, " Local structure
MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
END OF TY_MARA.
TYPES: TT_MARA TYPE TABLE OF TY_MARA.
5) in smartform Global parameters create work area WA_MARA TYPE TY_MARA
6) in smartform Field symbols create global fields symbol <IT_MARA> TYPE TT_MARA
7) in first code node dereference your parameter
ASSIGN IT_MARA->* TO <IT_MARA>. "now <IT_MARA> holds your data
"work with them via WA_MARA
😎 in local program call your smartform's FM and pass TS_MARA to IT_MARA
That's all you need. The only trouble I foreseen here is TT_MARA used for typing field symbol. Not sure if you don't need to use DDIC type here as well.
Regards
Marcin
‎2011 Dec 05 5:03 PM
Hi,
I didn't give up on it necessarily, I just think it adds too much additional work simply to keep the TYPE local. Define it in two places and get all of the references setup to retrieve the data properly as opposed to simply creating a global dictionary type in SE11 and spending 1 minute on it.
Regards,
Ryan Crosby
‎2011 Dec 06 8:07 AM
Obviously I agree. The best solution is the simplest usually. Here I was rather thinking of an alternative solution to global typings. DDIC typing have some downsides i.e. when you want to move smartform to different system then you need to move that definition too. For local typings you can always restore it on other's system local program.
Regards
Marcin
‎2011 Dec 06 8:24 AM
Hi Marcin/Ryan,
I think the solution you guys suggested is perfect albeit a little convoluted. (TT_MARA definition shouldnt cause a problem).
But like Ryan said, no one would take the trouble to do so much when it can be achieved easily...
Nice line of thinking.. Keep such solutions coming !
Regards,
Arun
‎2011 Dec 05 11:50 AM
Hi,
In types u have to define like this....
TYPES:BEGIN OF TY_MARA, " Local structure
MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
END OF TY_MARA.
Tyeps:it_mata type standard table of ty_mara. Internal Table
In form interface
It_mata type it_mara.......May be it will work(Try)
Or
In types u have to define like this....
TYPES:BEGIN OF TY_MARA, " Local structure
MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
END OF TY_MARA.
In form interface
it_mara type table of ty_mara
Regards
krishnakiran
‎2011 Dec 06 8:48 AM