‎2007 Dec 07 7:52 AM
i have copied the purchase order smart form and activated it and know i have the function moudule which need to be used in program but i am not shure how to do that can any one tell me how i need to write the coding for simple purchae order and then pass on the data to the smart form so that it displays the output.
‎2007 Dec 07 7:58 AM
Hi!
Smartforms are function modules, generated by SAP. To determine their names, you have to use the following FM in the printer program:
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZMYSMARTFORM'
IMPORTING
fm_name = lw_fm_name (Function Module Name)
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> c_0.
ENDIF.
CALL FUNCTION lw_fm_name
EXPORTING
control_parameters = l_cntrl_param
output_options = l_outpt_param
user_settings = space
fiw_wapinr = p_wapinr
fiw_desc = w_stxt
fiw_langu = w_spras
TABLES
fti_lines = i_long_text
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
You have to define printer program and smartform name in the NACE transaction for purchasing output type.
Regards
Tamá
‎2007 Dec 07 8:04 AM
What you do for inserting lines is to select line one of the screen table and then click the insert button.
Do this for each line in your BDC and then you only have to worry about line one of the table:
Code:
Form Add_Item_Line Tables t_Item_Data
using pu_program type Program_Name
pu_screen like sy-dynnr
pu_insert_line like sy-ucomm
pu_insert_at like sy-tabix
pu_werks like Zorder_Header-Dwerk.
Data: t_characteristics type Order_Lines,
w_Characteristic like Zorder_Line.
Perform Zbdc_Screen using pu_Program pu_Screen.
Perform Zbdc_Field using c_OkCode pu_insert_line. <----
Perform Zbdc_Screen using pu_Program pu_Screen.
Loop at t_Item_Data into w_Characteristic.
Is this actually part of the item line or is it a
Characteristic ?
Translate w_Characteristic-AtNam to Upper Case.
Case w_Characteristic-AtNam.
When 'MATNR'. " Material
Perform Zbdc_Subscript using 'VBAP-MATNR'
pu_insert_at
W_Characteristic-AtWrt.
Perform Zbdc_Subscript using 'VBAP-WERKS'
Looking at it from a modification point of view, the aim will be always to bring the line of the table that you're interested in to line one of the table
so again you only need to handle line one of the screen table. Some of the codes for this are 'POPO' in Purchase order processing, and 'SORT' in CO02:
Code:
Now loop round the P/O and delete all of those that we don't want
Loop at t_ekpo.
Keep this P/O Line item ?
MOVE SY-TABIX TO W_POPO.
PERFORM ZBDC_SCREEN USING 'SAPMV50A' '0270'.
PERFORM ZBDC_FIELD USING 'BDC_OKCODE' '=POPO'.
PERFORM ZBDC_SCREEN USING 'SAPMV50A' '0111'.
PERFORM ZBDC_FIELD USING 'RV50A-POSNR' W_POPO.
PERFORM ZBDC_FIELD USING 'BDC_OKCODE' '/00'.
Read Table t_vl31_asn with key ebeln = t_ekpo-ebeln
ebelp = t_ekpo-ebelp.
If sy-subrc <> 0.
Not found - discard this one.
PERFORM ZBDC_SCREEN USING 'SAPMV50A' '0270'.
PERFORM ZBDC_FIELD USING 'RV50A-LIPS_SELKZ(01)' 'X'.
ELSE.
Change the quantity....
WRITE T_VL31_ASN-MENGE TO W_MENGE UNIT T_VL31_ASN-LMEIN.
CONDENSE W_MENGE NO-GAPS.
PERFORM ZBDC_SCREEN USING 'SAPMV50A' '0270'.
PERFORM ZBDC_FIELD USING 'LIPS-LFIMG(01)' W_MENGE.
EndIf.
EndLoop.
Hope this helps.
Award points if found usefull.
Cheers,
Chandra Sekhar.
_________________