2009 Jul 06 2:10 PM
Hi All,
I have a requirement where i need to call smartform in a loop.
I have a customer number as a select option on the selection screen. I am getting all the customers in a internal table entered on the selection screen and by looping on this internal table I am calling the FM SSF_FUNCTION_MODULE_NAME.
But it is getting executed only for one customer.
Is there any variable or parameter needs to be set. I need this smartform to be called for every customer in the loop.
Please let me know the solution.
Thanks in advance,
Kuldeep.
Hi All,
I have a requirement where i need to call smartform in a loop.
I have a customer number as a select option on the selection screen. I am getting all the customers in a internal table entered on the selection screen and by looping on this internal table I am calling the FM SSF_FUNCTION_MODULE_NAME.
But it is getting executed only for one customer.
Is there any variable or parameter needs to be set. I need this smartform to be called for every customer in the loop.
Please let me know the solution.
Thanks in advance,
Kuldeep.
2009 Jul 06 2:13 PM
Hi Kuldeep,
USe FM
OPen_form
write_form
Close form.
Hope this will help you.
Regards,
Vijay
2009 Jul 06 2:15 PM
2009 Jul 06 2:18 PM
Hi Kuldeep,
We had somewhat similar requirement.
It was like we were displaying some Transfer Order data in ALV and after selecting particular line, we were dispalying that in Smartform.
If user selects multiple lines, we were giving error.
You can also show your customer data into ALV, then let user select single cuatomer and then display smartform for that customer.
Let me know if you need any explanation for this logic.
Regards,
Anil Salekar
2009 Jul 06 2:20 PM
Hi Kuldeep,
here there is a problem with passing data to the smartform.
first check when you call a smartform you willl be passing data to the smartform.
let me give you a example.
Dont call the FM 'SSF_FUNCTION_MODULE_NAME' this will decrease the performance of the code.
get the FM generated from 'SSF_FUNCTION_MODULE_NAME', call the Fm and pass your inside loop.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = lw_formname " Smartform Name
IMPORTING
fm_name = f_lw_fm_name " FM generated by the SSF FM
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at it_tab into wa_tab.
CALL FUNCTION f_lw_fm_name
EXPORTING
control_parameters = lw_control
output_options = w_output
user_settings = space
wa_zucc_label_printing = wa_tab " Send the data here ... the data will be sent properly to the smartform
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endloop.
hope this will solve your problem,
thanks,
vinayaka
2009 Jul 06 2:31 PM
Hi Vinayaka,
It is not working.....i tried to do that...but it goes only for one customer
2009 Sep 16 7:41 AM
2009 Sep 16 7:50 AM
try this it will definetly work, it is based on invoice change it to your requirement
create a another internal table with output structure
after select-option statement write;
define tb_vbeln internal table with only vbeln field
SELECT VBELN
FROM
VBRK
INTO TABLE TB_VBELN
WHERE VBELN IN P_VBELN.
then after ssf_function_module_name
LOOP AT TB_VBELN INTO WA_VBELN.
REFRESH TB_OUTPUT1.
LOOP AT TB_OUTPUT INTO WA_OUTPUT WHERE VBELN = WA_VBELN-VBELN.
APPEND WA_OUTPUT TO TB_OUTPUT1.
ENDLOOP.
CALL FUNCTION FM_NAME(function module name)
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS =
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS =
USER_SETTINGS = 'X'
P_VBELN = WA_OUTPUT-VBELN
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO =
JOB_OUTPUT_OPTIONS =
TABLES
TB_ITAB = TB_OUTPUT1
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.