on 09-20-2007 9:29 PM
Hi All,
I am testing a smartform for PO. But the smartform is already designed and it has two internal tables of type EKKO and EKPO. When i run the smartform its displaying the layout correctly but with no data ,which is true as the two internal tables have no data. So i want to fill those two internal tables based on the purchase order number/ numbers. So that i can test the smartform with those purchase order numbers.
I want to create a parameter / select option in smartform so that when we enter the PO number those internal tables will be filled. How to create those options in the smartform.
If i have to create through an ABAP program then i want to know how to pass those two internal tables to smartform. (Shall i have to call the FM couple of times and then pass those two internal tables).
Thanks in Advance
You fill the tables in the print program and pass the tables to the SmartForm function module under the tables section. See the FM call below (CALL FUNCTION lf_fm_name) and note that I am only passing in one internal table. If you wish you may pass in more than one table.
*&---------------------------------------------------------------------*
*& Form smartform_print
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM smartform_print .
DATA: lf_fm_name TYPE rs38l_fnam.
DATA: ls_control_param TYPE ssfctrlop.
DATA: ls_composer_param TYPE ssfcompop.
DATA: ls_recipient TYPE swotobjid.
DATA: ls_sender TYPE swotobjid.
DATA: lf_formname TYPE tdsfname.
DATA: ls_addr_key LIKE addr_key.
PERFORM set_print_param USING ls_addr_key
CHANGING ls_control_param
ls_composer_param
ls_recipient
ls_sender
retcode.
*Get the Smart Form name.
IF NOT tnapr-sform IS INITIAL.
lf_formname = tnapr-sform.
ELSE.
MESSAGE e001(/smb40/ssfcomposer).
ENDIF.
IF vbdkr-vkorg = '0035'.
IF w_regio = 'QC'.
tnapr-fonam = 'ZPCC_INVOICE_FR'.
ENDIF.
ENDIF.
* IF NOT tnapr-sform IS INITIAL.
* lf_formname = tnapr-sform.
* ELSE.
* MESSAGE e001(/smb40/ssfcomposer).
* ENDIF.
* determine smartform function module for invoice
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING formname = lf_formname
* variant = ' '
* direct_call = ' '
IMPORTING fm_name = lf_fm_name
EXCEPTIONS no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
* error handling
retcode = sy-subrc.
IF sy-subrc = 1.
MESSAGE e001(/smb40/ssfcomposer).
ENDIF.
IF sy-subrc = 2.
MESSAGE e002(/smb40/ssfcomposer).
ENDIF.
PERFORM protocol_update.
ENDIF.
CALL FUNCTION lf_fm_name
EXPORTING
archive_index = toa_dara
* ARCHIVE_INDEX_TAB =
archive_parameters = arc_params
control_parameters = ls_control_param
* MAIL_APPL_OBJ =
mail_recipient = ls_recipient
mail_sender = ls_sender
output_options = ls_composer_param
user_settings = ' '
vbdkr = vbdkr
temp_jmval = temp_jmval
temp_agval = temp_agval
w_ship = w_ship
w_ktgrd = w_ktgrd
likp = likp
w_trlrnbr = w_trlrnbr
w_sealnbr = w_sealnbr
w_booknbr = w_booknbr
w_lc = w_lc
w_shippoint = w_shippoint
billto_fedid = billto_fedid
soldto_fedid = soldto_fedid
shipto_fedid = shipto_fedid
vbco3 = vbco3
w_z4_address = w_z4_address
w_stawn = w_stawn
w_herkl = w_herkl
new_rate = new_rate
vblkp = vblkp
TABLES
vbdpr = tvbdpr
* t_containers = t_containers
* tdomvd = tkomvd
* da_xfplt = da_xfplt
* payment_split = payment_split
* komk = komk
* frt_conditions = frt_conditions
* IMPORTING
* DOCUMENT_OUTPUT_INFO =
* JOB_OUTPUT_INFO =
* JOB_OUTPUT_OPTIONS =
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5
.
IF sy-subrc <> 0.
retcode = sy-subrc.
PERFORM protocol_update.
* get SmartForm protocoll and store it in the NAST protocoll
PERFORM add_smfrm_prot.
ENDIF.
ENDFORM. " smartform_print
Davis
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your reply
I know how to pass a single table. But if we have to pass two tables can we pass the two tables at the same time as below.
*******************************************************************************************
CALL FUNCTION lf_fm_name
EXPORTING
archive_index = toa_dara
ARCHIVE_INDEX_TAB =
archive_parameters = arc_params
control_parameters = ls_control_param
MAIL_APPL_OBJ =
mail_recipient = ls_recipient
mail_sender = ls_sender
output_options = ls_composer_param
user_settings = ' '
vbdkr = vbdkr
temp_jmval = temp_jmval
temp_agval = temp_agval
w_ship = w_ship
w_ktgrd = w_ktgrd
likp = likp
w_trlrnbr = w_trlrnbr
w_sealnbr = w_sealnbr
w_booknbr = w_booknbr
w_lc = w_lc
w_shippoint = w_shippoint
billto_fedid = billto_fedid
soldto_fedid = soldto_fedid
shipto_fedid = shipto_fedid
vbco3 = vbco3
w_z4_address = w_z4_address
w_stawn = w_stawn
w_herkl = w_herkl
new_rate = new_rate
vblkp = vblkp
TABLES
<b>vbdpr = tvbdpr
itab = itab</b>
t_containers = t_containers
tdomvd = tkomvd
da_xfplt = da_xfplt
payment_split = payment_split
komk = komk
frt_conditions = frt_conditions
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO =
JOB_OUTPUT_OPTIONS =
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5
.
IF sy-subrc <> 0.
retcode = sy-subrc.
PERFORM protocol_update.
get SmartForm protocoll and store it in the NAST protocoll
PERFORM add_smfrm_prot.
ENDIF.
Thanks David,
Another problem i am getting is while passing the internal table from ABAP program i am not getting any output in Smartform. When i debug the internal table in ABAP program it is filled with data. How to check for the internal table in the smartform whether it is populated with the data. I doubt with the smartform internal table.
If you want to check and make sure that the table is filled just add a programs lines node anywhere in the form and type <b>break-point.</b> in that node. That will break and take you to the debugger. You can then check the table using the debugger. Another thing that you can do is add a program lines node in the table node (inside a table line) and, again, type <b>break-point.</b>. That will allow you to ensure that you are looping into the work area correctly.
You should be looping at the internal table into a work area and using the work area to display the fields.
Davis
Debug the FM (put a break point on the FM call and step into it). Before you step into it double check the table (in the debugger) and make sure that the tables are filled. Then check and see if the table is filled after you step into the FM. If it is take a few more steps and check it again. There is no reason, that I know of, for it not to be filled. Are either of them filled? I apologize for not being much help but I have never heard of a table being filled before the FM call and then not being filled after the FM call.
I am about to go to bed but I will check back tomorrow. If you don't find the error before the morning then export the form and send it to me. My email address is in my business card. I will debug the form and see if I can find the problem in the morning.
Davis
Davis,
I am working on this code on another SAP 4.7 server its working fine over there but in ECC6.0 server its not working. The ABAP code defined internal table is filled with data before and after calling the FM . But Smartform internal table is not populated with data. The ABAP code is as follows:
**********************************************************************************
tables: mara.
data :itab type standard table of mara,
FM_NAME TYPE RS38L_FNAM.
select * from mara into table itab.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZBPFORM'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = FM_NAME
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.
CALL FUNCTION FM_NAME
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS =
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS =
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO =
JOB_OUTPUT_OPTIONS =
TABLES
itab = itab
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.
*******************************************************************************************
In ZBPFORM i declared as follows:
Global declaration: itab type standard table of mara
wtab type mara
in main window in loop i assigned i tab into wtab and created a text to display these fields.
***************************************************************************
Just for testing the functionality i developed the sample code. Sorry for not having any comments and documentation.
You should not be defining itab in the global declarations section; you should be declaring it in the form interface on the tables tab. I assume that is what you are doing or you would be getting a dump when you call the FM. Make sure that you did not declare itab in both places. I am not sure if this is possible (I would think that it would give you a syntax error) but if it is possible it may be looking at the global itab instead of the interface itab.
If you do not have itab declared in both places, but only in the interface (tables tab), then I am not sure what is causing the problem. I am on ECC 5.0 so it may act differently but I wouldn't think that it would. From my understanding ECC 5.0 and 6.0 are basically the same.
Davis
Hi Davis,
I fixed the problem and smartform is working fine. i developed PO Smartform from scratch along with print program. Now i want to assign this in the nace transaction. But before that i have to assign the PO number which is created in me21n to my print program. Do you have any idea how to link PO number to a print program.
Ben,
Are you saying that you want to assign an individual PO number to the SF? I am not sure how you would do that or why you would want to do that. Can you explain the requirements? If you want a range of PO numbers (or a specific number) to use a certain form (one that is different from other PO forms) then I would just put that logic in the print program and give it the name of the form. Otherwise I am not clear as to what your requirements are.
Davis
I developed a Smartform and print program in such a way that when we run the print program it will ask for PO number in selection screen. When we enter the PO and execute the smartform will display the corresponding details. Now my requirement is when the PO is created in me21n then it has to execute the print program and smartform automatically.
I would imagine that you would want to use a user exit for that, well actually a badi. I believe that the badi ME_PROCESS_PO_CUST will enable you to do what you are asking. Also you can try to find your badi by doing an SQL trace on that transaction. If you want more information on how to do that here is a great blog on that topic.
/people/alwin.vandeput2/blog/2006/04/13/how-to-search-for-badis-trace-it
I would start by looking for a badi on the save and you could then call your print program when the save is pressed (if that is the event that you want to trigger it). Even if you do not go this route I would still read the above link and bookmark it. I know that I have found it very useful in the past.
I hope this helps.
Davis
User | Count |
---|---|
96 | |
11 | |
11 | |
10 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.