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

Call sapscript form from an OO class method?

Former Member
0 Likes
1,475

Hi,

I'm trying to call a sapscript from a class method like:

method mymethod.

call function 'OPEN_FORM'.....

call function 'START_FORM'......

call function 'WRITE_FORM'....

.....

endmethod.

The layout and the fixed texts comes out correctly and I can print the form;

BUT

All the variable fields are lost!

In a normal program I define:

data: mymara type mara.

perform: fill_mymara.

call function 'WRITE_FORM'

...and mymara is available in the script and I can use it like:

&mymara-matnr&

But If I do the same inside a method..... NOTHING!

So the question:

Do you know I can I pass the data to a form from a OO class method?

Many thanks,

Lorenzo

6 REPLIES 6
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,039

Where are you declaring your variable fields, in the method?, in the the class definintion?, in the main program?

SAPscript is a little picky about that. You may want to try declaring them in the class definintion in the Public section or in the main program itself.

Regards,

Rich Heilman

Read only

0 Likes
1,039

Just tested it. Think that you are going to have to put these variables outside of the class definintion/implemenation. You can still access them inside the class, so this should work for you.

Regards,

Rich Heilman

Read only

0 Likes
1,039

Ooooops! I can't!

I have no main program. There's no "outside". My transaction calls directly a method of my "handler" class.....

Well, I think I can create a main program but doing it just for this.... I don't like it at all.

Do you think that moving to smartform I can find better luck? (I'm just at the early development of the form). I've never done a smartform but maybe it worth a try...

Thanks,

Lorenzo

Read only

0 Likes
1,039

Yep, that would be a problem if calling the method directly.

I've messed with Smartforms a little, but never really did a smartform that is in use in a productive system. I am not sure if they are as "picky" as sapscript forms. I would give it a try if you have the time.

Also, I realize that you probably want to use OO because its "new", I feel the same way, but in this particular case, you would probably be better off writing the print program in classic ABAP. Especially, if the output is to be trigger by configuration. In some cases, the configuration may only handle "regular" programs with the SAPscript form. Just a suggestion.

Regards,

Rich Heilman

Read only

0 Likes
1,039

Rich,

you're being very helpful.

As a matter of fact, even though I have been in SAP since 1998 (MM, SD..), I've been "messing around" in ABAP only for a year or so. Since I have to learn ABAP almost "from scratch" I thought of jumping straight to OO, since I see a lot of potential advantages.

As a matter of fact I have to jump in an out of OO for almost all of GUI controls, but I've wrapped most of them.

I've no idea of what do you mean by "configuration" but I have the feeling it is not my case...

Regarding smartforms: I've migrated my draft sapscript to a smartform and put a "call function" from my OO method and it works smoothly.

I like that you have to pass explicitly in the call all the parameters/tables you want to print. Much more clean in my opinion.

So I think I'm going in that direction. I suppose it'll be a little effort at the beginning but otherwise programming would be boring....

I'll write my results later.

Ciao,

Lorenzo

Read only

0 Likes
1,039

Hello Lorenzo & Rich,

I am having exact requirement except that the output type i.e RAW_DATA_INTERFACE in OPEN_FORM is I (IDOC) for me.

All my variables declared in the method are not getting printed but those STATIC variables of the class mentioned as ZCL_CLASS=>FIELD1  are printed correctly.

How did you manage to print the normal variables ? Did you define them outside of CLASS definition / implementation ?

I am not sure I can add the variable definitions outside class as my class is generated from SE24 and i have no idea how to navigate to the source code.

Really appreciate your replies.

Thanks

BR

Nilesh