09-17-2007 9:34 PM
Lorenzo Nicora posted in the Forum: and solved his problem with smartforms. Im with the same problem, but I cant change to smartforms.
I tried to use static data in the sapscrit (&lcl_class=>my_data&) but with this Im instantiate a new object and the variable are empty, and with the object like (&obj=>my_data&) the sapscript dont recognize the variable.
So, I do the same question that Lorenzo did: Do you know How can I pass the data to a form from a OO class method?
09-18-2007 1:18 PM
Try to use
PERFORM provide_object IN PROGRAM <prog> CHANGING &LCL_CLASS&
and in your program
FORM provide_object CHANGING io_obj TYPE REF TO object.
io_obj ?= my_instance.
ENDFORM.
then you should be able to access to attributes of your instance...
09-18-2007 3:10 PM
It was a good tip but it didn't solve my problem, I tried to use:
In the program:
FORM provide_object1 CHANGING ch_obj TYPE REF TO lcl_grupo_atividade.
ch_obj = obj. I dont need to use widening cast here, the scope is the same
ENDFORM.
In the SAPscript
/: PERFORM PROVIDE_OBJECT1 IN PROGRAM ZPWTSOAC100
/: CHANGING &CH_OBJ&.
/: PERFORM
,,EMPRESA2,,: &CH_OBJ->V_EMRPE&
The error:
Do you have any other suggestion?
09-19-2007 7:34 AM
09-19-2007 10:50 AM
OK then it will be a bit more "hand-made"
you have to create a form routine that you will call from the SAPScript
this form routine has one incoming parameters: name of attribute and one changing parameter : value
according to attribute name, you return the value that you get from the class
sorry but I don't see any other way...
09-19-2007 7:43 PM
<b>PROGRAM</b>
CLASS lcl_grupo_atividade DEFINITION.
...
ENDCLASS.
CLASS lcl_grupo_atividade IMPLEMENTATION.
...
ENDCLASS.
START-OF-SELECTION.
DATA obj TYPE REF TO lcl_grupo_atividade.
CREATE OBJECT obj.
CALL METHOD obj->main.
FORM provide_main TABLES itab STRUCTURE itcsy
...........................................otab STRUCTURE itcsy.
MOVE 'SS_TRANSACAO' TO otab-name.
MOVE obj->ss_transacao TO otab-value.
MODIFY otab INDEX 1.
MOVE 'SS_DESCRICAO' TO otab-name.
MOVE obj->ss_descricao TO otab-value.
MODIFY otab INDEX 2.
ENDFORM.
<b>SAPSCRIPT:</b>
/E MAIN
/* BOX FRAME 30 TW
/: PERFORM PROVIDE_MAIN IN PROGRAM ZPWTSOAC100
/: CHANGING &SS_TRANSACAO&
/: CHANGING &SS_DESCRICAO&
/: ENDPERFORM
P2 ,,&ss_transacao&,,&ss_descricao&
*******************************************************************************************
I code in this way, its works but, I think that have a better way, because I had to use public variables and code a FORM outside of my class.
What do you think? Do you think exist another way to do that?
By the way, thanks for the help, I cant find that without you.
09-20-2007 8:25 AM
Hi Bruno,
im not a SAP Script specialist, but i uderstand it like this: the SAPScript processor needs for technical reasons a form to communicate with the program.
My opinion is: Because of this you need a form, but the form does not to have any functionality, it have to be only the "Interface" of your business logic for the SAPSCRIPT processor.
The form could be something like that:
FORM provide_main TABLES itab STRUCTURE itcsy
.........................otab STRUCTURE itcsy.
CALL METHOD obj->provide_main
CHANGING
ch_itab = itab[]
ch_otab = otab[].
ENDFORM.
So do you have no logic outside your OO modeled business logic. Just a form that encapsulate your public method provide_main.
Can i explane my view?
Regards,
Gianpietro
09-20-2007 12:23 PM