2007 Apr 18 6:57 AM
hi all,
i want to pass 2 internal tables data to smartform for that i have merged that table into final internal table.
and i want to pass this to smartform. for that without creating structure for that final internal table which statement i can write in form interface section.
i can declare this table in to types tab of global defination section. wht can i do in form interface.
thanks in advance.
regards,
vinod
hi all,
i want to pass 2 internal tables data to smartform for that i have merged that table into final internal table.
and i want to pass this to smartform. for that without creating structure for that final internal table which statement i can write in form interface section.
i can declare this table in to types tab of global defination section. wht can i do in form interface.
thanks in advance.
regards,
vinod
2007 Apr 18 7:02 AM
Hi
u have to call the Smartform from a Program. In the program you will call the FM (which will be created automatically by the system with the parameters required for smartform and it will call smartform automaticaaly by executing the Function Module.
So you have to pass the Internal table's data to the Function Module.
here is a sample program.
TABLES:
VBAK, " Sales Document: Header Data
SSCRFIELDS. " Fields on selection screens
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-B01.
SELECTION-SCREEN SKIP.
PARAMETERS:
P_ORDER TYPE VBAK-VBELN
DEFAULT '5043' OBLIGATORY. " Sales Document
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK B1.
DATA:
W_BILL_ADRNR TYPE KNA1-ADRNR, " Bill-to-party address number
W_SHIP_ADRNR TYPE KNA1-ADRNR, " Ship-to-party address number
W_SOLD_ADRNR TYPE KNA1-ADRNR, " Sold-to-party address number
W_TOTAL TYPE P DECIMALS 2. " Total amount
DATA:
W_FORM_NAME TYPE TDSFNAME
VALUE 'ZYH631_ORDER_CONFIRMATION', " Smart form name
W_FN_MODULE TYPE RS38L_FNAM, " Function module name
BIN_FILE TYPE I. " Binary file size for PDF
Field string for item details
DATA:
BEGIN OF FS_ORDERS,
POSNR TYPE VBAP-POSNR, " Sales Document Item
MATNR TYPE VBAP-MATNR, " Material Number
ARKTX TYPE VBAP-ARKTX, " Short text for sales order item
NETWR TYPE VBAP-NETWR, " Net value of the order item
WAERK TYPE VBAP-WAERK, " SD document currency
KWMENG TYPE VBAP-KWMENG, " Cumulative order quantity
VRKME TYPE VBAP-VRKME, " Sales unit
NTGEW TYPE VBAP-NTGEW, " Net Weight of the Item
GEWEI TYPE VBAP-GEWEI, " Weight Unit
NETPR TYPE VBAP-NETPR, " Net price
END OF FS_ORDERS.
Field string for partner addresses
DATA:
BEGIN OF FS_ADDR_NUMS,
PARVW TYPE VBPA-PARVW, " Partner function
KUNNR TYPE VBPA-KUNNR, " Customer
ADRNR TYPE KNA1-ADRNR, " Address
END OF FS_ADDR_NUMS.
Field string for other details of the Sales document
DATA:
BEGIN OF FS_OTHERS,
VBELN TYPE VBAK-VBELN, " Sales Document
VKGRP TYPE VBAK-VKGRP, " Sales Group
S_BSTDK TYPE VBAK-BSTDK, " Customer purchase order date
ZTERM TYPE VBRK-ZTERM, " Terms of payment key
INCO1 TYPE VBKD-INCO1, " Incoterms (part 1)
INCO2 TYPE VBKD-INCO2, " Incoterms (part 2)
BSTKD TYPE VBKD-BSTKD, " Customer purchase order number
P_BSTDK TYPE VBKD-BSTDK, " Customer purchase order date
BTGEW TYPE LIKP-BTGEW, " Total Weight
etdat TYPE vbep-EDATU,
END OF FS_OTHERS.
Field string for OTF data
DATA:
W_CONTROL_PARS TYPE SSFCTRLOP, " For CONTROL_PARAMETERS
W_OUTPUT_INFO TYPE SSFCRESCL. " For JOB_OUTPUT_INFO
Internal tables for OTF data and PDF download
DATA:
T_LINES TYPE STANDARD TABLE OF TLINE,
T_DOCS TYPE STANDARD TABLE OF DOCS,
T_OTFDATA TYPE STANDARD TABLE OF ITCOO.
Internal table for storing item details
DATA:
T_ORDERS LIKE
STANDARD TABLE
OF FS_ORDERS.
Internal table for storing partner addresses
DATA:
T_ADDR_NUMS LIKE
STANDARD TABLE
OF FS_ADDR_NUMS.
************************************************************************
AT SELECTION-SCREEN EVENT *
************************************************************************
AT SELECTION-SCREEN ON P_ORDER.
PERFORM VALIDATE_ORDER.
************************************************************************
START-OF-SELECTION EVENT *
************************************************************************
START-OF-SELECTION.
PERFORM GET_ORDER_DETAILS.
PERFORM GET_OTHER_DETAILS.
PERFORM GET_ADDRESS_NUMBERS.
PERFORM GET_SF_NAME.
PERFORM CALL_SF_FN_MODULE.
&----
*& Form VALIDATE_ORDER *
&----
This subroutine validates the Sales Document number given by user *
----
This subroutine has no interface parameters *
----
FORM VALIDATE_ORDER .
SELECT SINGLE VBELN
FROM VBUP
INTO VBAK-VBELN
WHERE VBELN = P_ORDER.
IF SY-SUBRC NE 0.
CLEAR SSCRFIELDS-UCOMM.
MESSAGE 'Invalid Sales Document number' TYPE 'E'.
ENDIF.
ENDFORM. " VALIDATE_ORDER
&----
*& Form GET_ORDER_DETAILS *
&----
text
----
This subroutine has no interface parameters *
----
FORM GET_ORDER_DETAILS .
SELECT POSNR " Sales Document Item
MATNR " Material Number
ARKTX " Short text for sales order item
NETWR " Net value of the order item
WAERK " SD document currency
KWMENG " Cumulative order quantity
VRKME " Sales unit
NTGEW " Net Weight of the Item
GEWEI " Weight Unit
NETPR " Net price
FROM VBAP
INTO CORRESPONDING FIELDS OF TABLE T_ORDERS
WHERE VBELN = P_ORDER.
IF SY-SUBRC EQ 0.
LOOP AT T_ORDERS INTO FS_ORDERS.
W_TOTAL = W_TOTAL + FS_ORDERS-NETWR.
ENDLOOP.
ELSE.
MESSAGE 'No items found for given Order number' TYPE 'S'.
STOP.
ENDIF.
ENDFORM. " GET_ORDER_DETAILS
&----
*& Form get_other_details
&----
text
----
--> p1 text
<-- p2 text
----
FORM GET_OTHER_DETAILS .
SELECT SINGLE VBELN
VKGRP
BSTDK
FROM VBAK
INTO (FS_OTHERS-VBELN, FS_OTHERS-VKGRP, FS_OTHERS-S_BSTDK)
WHERE VBELN = P_ORDER.
SELECT SINGLE ZTERM
FROM VBRK
INTO (FS_OTHERS-ZTERM)
WHERE VBELN = P_ORDER.
SELECT SINGLE INCO1
INCO2
BSTKD
BSTDK
FROM VBKD
INTO (FS_OTHERS-INCO1, FS_OTHERS-INCO2,
FS_OTHERS-BSTKD, FS_OTHERS-S_BSTDK)
WHERE VBELN = P_ORDER.
SELECT SINGLE BTGEW
FROM LIKP
INTO (FS_OTHERS-BTGEW)
WHERE VBELN = P_ORDER.
ENDFORM. " get_other_details
&----
*& Form GET_ADDRESS_NUMBERS
&----
text
----
--> p1 text
<-- p2 text
----
FORM GET_ADDRESS_NUMBERS .
DATA:
LW_LINES TYPE SY-INDEX.
SELECT VBPA~PARVW " Partner function
VBPA~KUNNR " Customer
KNA1~ADRNR " Address
INTO TABLE T_ADDR_NUMS
FROM VBPA AS VBPA
INNER JOIN KNA1 AS KNA1
ON VBPAKUNNR = KNA1KUNNR
WHERE VBPA~VBELN = P_ORDER
AND VBPA~PARVW IN ('RE', 'WE', 'AG').
IF SY-SUBRC NE 0.
REFRESH T_ADDR_NUMS.
EXIT.
ELSE.
DESCRIBE TABLE T_ADDR_NUMS LINES LW_LINES.
IF LW_LINES GT 3.
SORT T_ADDR_NUMS BY PARVW.
DELETE ADJACENT DUPLICATES FROM T_ADDR_NUMS.
ENDIF.
ENDIF.
LOOP AT T_ADDR_NUMS INTO FS_ADDR_NUMS.
CASE FS_ADDR_NUMS-PARVW.
WHEN 'RE'.
W_BILL_ADRNR = FS_ADDR_NUMS-ADRNR.
WHEN 'WE'.
W_SHIP_ADRNR = FS_ADDR_NUMS-ADRNR.
WHEN 'AG'.
W_SOLD_ADRNR = FS_ADDR_NUMS-ADRNR.
ENDCASE.
ENDLOOP.
ENDFORM. " GET_ADDRESS_NUMBERS
&----
*& Form GET_SF_NAME *
&----
This subroutine gets the Smart form name which has to be invoked for *
obtaining the required output print form. *
----
This subroutine has no interface parameters *
----
FORM GET_SF_NAME .
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = W_FORM_NAME
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = W_FN_MODULE
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.
ENDFORM. " GET_SF_NAME
&----
*& Form CALL_SF_FN_MODULE
&----
text
----
--> p1 text
<-- p2 text
----
FORM CALL_SF_FN_MODULE .
w_control_pars-no_dialog = 'X'.
w_control_pars-getotf = 'X'.
CALL FUNCTION W_FN_MODULE "'/1BCDWB/SF00000151'
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = W_CONTROL_PARS
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS =
USER_SETTINGS = 'X'
W_TOTAL = W_TOTAL
FS_OTHERS = FS_OTHERS
W_BILL_ADRNR = W_BILL_ADRNR
W_SHIP_ADRNR = W_SHIP_ADRNR
W_SOLD_ADRNR = W_SOLD_ADRNR
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = W_OUTPUT_INFO
JOB_OUTPUT_OPTIONS =
TABLES
T_ORDERS = T_ORDERS
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.
2007 Apr 18 7:03 AM
Hi.,
You need to create a TABLE TYPE in SE11 for the form interface..
First create the structure in se11 with the required fields.. (Observe, while creating the structure u will get a window to select whether to create a STRUCTURE or DATA ELEMENT or TABLE TYPE ) .. come back and create a table type in the same way, by selecting TABLE TYPE in that window..
Now use this in the form interface !!
regards,
sai ramesh
2007 Apr 18 7:13 AM
hi
first declare this table in to types tab of global defination section
when u will call the function module <b><SSF_FUNCTION_MODULE_NAME</b>> in the print program
<b>already it will ask u to pass the table as an export parameter in tables</b>. u pass this table u have declared in the print program.
<b>note: the table name should be same in print program, and global declaration</b>
regards
ravish
<b>plz dont forget to reward points if helpful</b>
2007 Apr 18 10:01 AM
thanks ravish,
i have tested your solution but therre is no any options to enter the table in function module given by u.
whts is the exact function module for that.
regards,
vinod
2007 Apr 18 10:09 AM
Hi Vinod,
SSF_FUNCTION_MODULE_NAME will give u the Function Modulke associated with the smartform. Once u get that function, then u need to pass the table in the tables parametr of that function.
In SSF_FUNCTION_MODULE_NAME u need to pass the layout set i.e. Smartform name and u will get the associated FM.
U can use the function as below:
DATA : FM_NAME TYPE RS38L_FNAM.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'Z_FORM_RMA'
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 = TOA_DARA
ARCHIVE_INDEX_TAB = ARC_PARAMS
ARCHIVE_PARAMETERS = ARC_PARAMS
CONTROL_PARAMETERS =
MAIL_APPL_OBJ =
MAIL_RECIPIENT = LVS_RECIPIENT
MAIL_SENDER = LVS_SENDER
OUTPUT_OPTIONS = LVS_ITCPO
USER_SETTINGS = 'X'
PAGE = 1
LAND = W_LAND
AENDE = W_AENDE
ABGRU = W_ABGRU
WERKS = W_WERKS
REPEAT = W_REPEAT
CO_NAME = CO_NAME
VBDKA = VBDKA
KOMK = KOMK
SOLDTO = SOLD_TO
SHIPTO = SHIP_TO
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO =
JOB_OUTPUT_OPTIONS =
TABLES
KOMVD = TKOMVD
ITEM_DATA = T_ITEM
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.
Hope it helps.
Regards,
Himanshu
Message was edited by:
Himanshu Aggarwal
2007 Apr 18 7:26 AM
Hi Vinod,
In the global definitions define an structure which should match ur final internal table.Then in the form interface tables tabstrip defie an table of this type.
Regards,
Shafi
2007 Apr 18 10:19 AM
Hi Vinod,
Let t_final be the Final internal table and am passing this internal into the smartform.
T_final is declared in print program as given below:-
t_final TYPE STANDARD TABLE OF zfinal_data,( "Z" Structure created )
<u><b>*This Function Returns the name of generated Function Module.</b></u>
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = c_fmname
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
fm_name = w_fmname
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3
.
IF sy-subrc NE 0.
EXIT.
ENDIF.
<u><b>*To call the generated Function Module in the above step</b></u>.
CALL FUNCTION w_fmname
EXPORTING
w_header = w_header
w_adrc = w_adrc
w_adrc_forw = w_adrc_forw
w_adrc_comp = w_adrc_comp
TABLES
t_final = t_final
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4.
Then in the FORM interface in "Tables" Tab
declare - t_final like zfinal_data...
Try this it may solve ur problem
regards
Avi...........
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |