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

using local structure in smartforms

naresh_bammidi
Contributor
0 Likes
2,530

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 ?

11 REPLIES 11
Read only

Former Member
0 Likes
2,110

create a custom structure and use that.

Read only

0 Likes
2,110

you mean to say,Local structure or dictionary structure?

Read only

0 Likes
2,110

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

Read only

0 Likes
2,110

Hi,

Can't we create smartforms using local structure which is defined in Driver program?

With regards

Naresh

Read only

0 Likes
2,110

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

Read only

0 Likes
2,110

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

Read only

0 Likes
2,110

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

Read only

0 Likes
2,110

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

Read only

0 Likes
2,110

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

Read only

Former Member
0 Likes
2,110

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

Read only

naresh_bammidi
Contributor
0 Likes
2,110

Thanks for your valuble replies.

Happy programming