cancel
Showing results for 
Search instead for 
Did you mean: 

Sap script doesn't work inside a function module

Former Member
0 Kudos

hi experts,

i created a function module and add open_form write_form close_form inside it, now the layout of this script is fine, but variable which needs to be transferred from this function module into the script are failed. could anyone tell me how to transfer parameter into sap script when it's inside a FM?

thanks in advance.

Desmond.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Where have you defined the attributes for the form?

You have only access to global attributes. Do not declare them in the function modul.

Regards,

Christian

Former Member
0 Kudos

hi Chiristian,

thanks for your info. i know it should be a global variable. i'll tell you my requirement from beginning.

user's requirement is sending mail thru Workflow with a PDF attachment, PDF is designed with sap script. Hence i have to create a FM(it can create PDF and send mail), then add this FM into a BOR as its method, then create a Workflow step with this method.

usually we print a PO, it contains more than one item, hence i have to follow below procedure.

open_form

loop into Workarea(it should be global data)

write_form(for item)

endloop

close_form

now the difficulty is that how to define the workarea as global.

i have a draft solution. define workarea in the container of workflow,then loop the item into this workarea and put the sendmail FM into the loop. but it's too complex.

do you have any simple way?

Thanks in advance for your kindly help.

Desmond.

Former Member
0 Kudos

Hi,

ok that`s true.

have you tried to include a subroutine with:


/: PERFORM <subroutine> IN PROGRAM <z_prog>
/: USING &VAR1&
/: ENDPERFORM

So it could be possible to access your data by loading the new program z_prog and transfer.

You can also import tables with the addition


/: PERFORM <subroutine> IN PROGRAM <z_prog> TABLES INPUT_TABLE OUTPUT_TABLE IF FOUND

Regards,

Christian

(I have no more ideas.....:-) )

Former Member
0 Kudos

thanks Christian,

i used a stupid way, submit a program inside the FM, it works,but i don't like it.

Desmond

Former Member
0 Kudos

Hi Desmond,

The variable declared in the driver program will be mapped 1 -to - 1. So just assign the value before the function modu;e write_form. Please use the same variaiable name in the script between the & sign.

For instance, if the variable gv_name is assigned with the value 'Victor' and in the script the same is assigned as &GV_NAME&, the write_form FM will replace the variable &GV_NAME& with the value 'Victor'.

If your qn is diff. please let me know with a suitable example.

Regards,

Selva K.