on 09-26-2007 7:39 PM
Hi All,
Can anyone let me know how to create Purchase order layout using smartforms and assigning it to output type.
Is there standard smartform for purchase order?
http://www.sap-basis-abap.com/sapsf001.htm
http://help.sap.com/printdocu/core/Print46c/de/data/pdf/BCSRVSCRSF/BCSRVSCRSF.pdf
http://www.sap-img.com/smartforms/smartforms-faq-part-two.htm
http://www.esnips.com/doc/97acb00a-e513-4611-91f0-c626f460bfc5/Smart_Form_Overview.pdf
http://www.esnips.com/doc/77a981b9-8fe3-4fbb-8101-67745c1fe60c/SMART-FORMS_shail.ppt
http://www.sap-basis-abap.com/sapsf001.htm
http://www.sap-press.com/downloads/h955_preview.pdf
http://www.ossincorp.com/Black_Box/Black_Box_2.htm
http://www.sap-img.com/smartforms/sap-smart-forms.htm
Try this. A simple sample Smart Form.
SAP Smartforms can be used for creating and maintaining forms for mass printing in SAP Systems. The output medium for Smartforms support printer, fax, e-mail, or the Internet (by using the generated XML output).
According to SAP, you need neither have any programming knowledge nor use a Script language to adapt standard forms. However, basic ABAP programming skills are required only in special cases (for example, to call a function module you created or for complex and extensive conditions).
1. Create a new smartforms
Transaction code SMARTFORMS
Create new smartforms call ZSMART
2. Define looping process for internal table
Pages and windows
First Page -> Header Window (Cursor at First Page then click Edit -> Node -> Create)
Here, you can specify your title and page numbering
&SFSY-PAGE& (Page 1) of &SFSY-FORMPAGES(Z4.0)& (Total Page)
Main windows -> TABLE -> DATA
In the Loop section, tick Internal table and fill in
ITAB1 (table in ABAP SMARTFORM calling function) INTO ITAB2
3. Define table in smartforms
Global settings :
Form interface
Variable name Type assignment Reference type
ITAB1 TYPE Table Structure
Global definitions
Variable name Type assignment Reference type
ITAB2 TYPE Table Structure
4. To display the data in the form
Make used of the Table Painter and declare the Line Type in Tabstrips Table
e.g. HD_GEN for printing header details,
IT_GEN for printing data details.
You have to specify the Line Type in your Text elements in the Tabstrips Output options.
Tick the New Line and specify the Line Type for outputting the data.
Declare your output fields in Text elements
Tabstrips - Output Options
For different fonts use this Style : IDWTCERTSTYLE
For Quantity or Amout you can used this variable &GS_ITAB-AMOUNT(12.2)&
5. Calling SMARTFORMS from your ABAP program
REPORT ZSMARTFORM.
Calling SMARTFORMS from your ABAP program.
Collecting all the table data in your program, and pass once to SMARTFORMS
SMARTFORMS
Declare your table type in :-
Global Settings -> Form Interface
Global Definintions -> Global Data
Main Window -> Table -> DATA
Written by : SAP Hints and Tips on Configuration and ABAP/4 Programming
TABLES: MKPF.
DATA: FM_NAME TYPE RS38L_FNAM.
DATA: BEGIN OF INT_MKPF OCCURS 0.
INCLUDE STRUCTURE MKPF.
DATA: END OF INT_MKPF.
SELECT-OPTIONS S_MBLNR FOR MKPF-MBLNR MEMORY ID 001.
SELECT * FROM MKPF WHERE MBLNR IN S_MBLNR.
MOVE-CORRESPONDING MKPF TO INT_MKPF.
APPEND INT_MKPF.
ENDSELECT.
At the end of your program.
Passing data to SMARTFORMS
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = 'ZSMARTFORM'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = FM_NAME
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
if sy-subrc <> 0.
WRITE: / 'ERROR 1'.
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
GS_MKPF = INT_MKPF
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.
SMARTFORMS GENERATION: (calling internal table fields)
 Open a smartform using the tcode smartforms.
 Usually form attributes shows admn data.
 In the form interface declare import/export parameters if any. Else declare the tables in tables tab button.
 In the windows and pages expand and create a table. It automatically generates header, main area and footer for the table.
 In data tab button in the table we usually declare a work area to bring the data from se38. Like: ktab into wa. ( The purpose of declaring the wa is , to get the data of the ktab in to header from the body area of the internal table).
 And in the tablepainter pushbutton in table we can have any no of line types. Depending on the requirement. ( for ex: If we want to devide a row in to 4 columns, we can devide it as 4,4,4,4cm as line type 1, And usually for the footer we dont need no of columns, So, we declare it as one column with 16cm measure with the name line type 2.). We can use these line types in the tables.
 In the header right click>>create>>tableline. It asks for line type. Select one line type which is appropriate.
 Like same create a row2 in main area using right click. If we select the line type 1, it automatically generates 4 cells. We can create text in each cell as per requirement.
 We can generate general attributes using general attributes tab button in the text. Or in the other way. We can switch on the field list on/off button from the application tool bar. It displays all the attributes in the left down corner of the screen. We can drag and drop the required fields in the general attributes tab button of the text.
 We continue the same procedure for all the texts. The texts should be displayed in the gray color. Then only it can collects the data from the abap editor fields.
 If it wont turns gray, we can check the fields in the editor by changing it to the line editor. The best thing is to drag the fields from the list, rather than declaring like &wa-matnr&
 In the footer also we create a line type and in that table line we create text.
SE38 PROGRAM(method I):
REPORT Z_CALLING_SMARTFORM2 .
tables: mara.
select-options: S_MATNR for MARA-MATNR.
DATA: kTAB LIKE MARA OCCURS 1 WITH HEADER LINE.
data: FM_NAME TYPE RS38L_FNAM.
SELECT * FROM MARA INTO TABLE kTAB WHERE MATNR in
S_MATNR.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'Z_MYFIRST_FORM2'
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
ktab = ktab
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 THE OTHER WAY(method II):
REPORT Z_CALLING_SMARTFORM2 .
tables: mara.
select-options: S_MATNR for MARA-MATNR.
DATA: kTAB LIKE MARA OCCURS 1 WITH HEADER LINE.
SELECT * FROM MARA INTO TABLE kTAB WHERE MATNR in S_MATNR.
CALL FUNCTION '/1BCDWB/SF00000199'
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
ktab = ktab
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 the method I we are calling the amartform dynamically using the function module 'SSF_FUNCTION_MODULE_NAME'.
Here we are exporting form name and importing fm_name.
So we need to declare the variable fm_name as
data: FM_NAME TYPE RS38L_FNAM.
We can have the type of the fm_name in the function module 'SSF_FUNCTION_MODULE_NAME' (in the export tab button).
Since we are passin the name of the Function module generated by the smart form in to the fm_name variable. We run the function module with the name fm_name, but not the FM generated by the smartform(like /1BCDWB/SF00000199)¬¬¬¬¬¬.
In the method II we directly call the smartform generated function module (i.e, /1BCDWB/SF00000199).
But the method I is recommended. In the method I, The fm_name is a variable we dont put it in the quotes while calling.
In the both methods we declare the internal table using the like option, but not begin of . end of. And in select statement we select *, But not individual fields.
EX2:
SMART FORM NAME: ZGITI_FORM1.
SE38:
REPORT Z_CALL_GIRI_FORM1 .
TABLES: VBRK.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE T1.
SELECT-OPTIONS: S_VBELN FOR VBRK-VBELN.
SELECTION-SCREEN END OF BLOCK B1.
*INITIALIZATION.
*T1 = 'SELECTION-CRIETERIA'.
DATA: BEGIN OF I_INVOICE OCCURS 1.
INCLUDE STRUCTURE ZSTR_INVOICE.
DATA: END OF I_INVOICE.
DATA: VAR1 LIKE VBRP-NETWR.
DATA: BEGIN OF I_ADDRESS OCCURS 1.
INCLUDE STRUCTURE ZSTR_ADDRESS.
DATA: END OF I_ADDRESS.
DATA: BEGIN OF I_ORDER OCCURS 1.
INCLUDE STRUCTURE ZSTR_ORDER.
DATA: END OF I_ORDER.
DATA: BEGIN OF I_ITEM OCCURS 1.
INCLUDE STRUCTURE ZSTR_ITEM.
DATA: END OF I_ITEM.
DATA: BEGIN OF I_VBFA OCCURS 1,
VBELV LIKE VBFA-VBELV,
VBELN LIKE VBFA-VBELN,
END OF I_VBFA.
SELECT KUNAG VBELN VKORG VTWEG SPART FROM VBRK INTO TABLE I_INVOICE
WHERE VBELN IN S_VBELN.
IF I_INVOICE[] IS NOT INITIAL.
SELECT KUNNR LAND1 NAME1 NAME2 ORT01 PSTLZ REGIO FROM
KNA1 INTO CORRESPONDING FIELDS OF TABLE I_ADDRESS FOR ALL ENTRIES IN
I_INVOICE WHERE KUNNR = I_INVOICE-KUNAG.
ENDIF.
IF I_INVOICE[] IS NOT INITIAL.
SELECT VBELV VBELN FROM VBFA INTO TABLE I_VBFA FOR ALL ENTRIES IN
I_INVOICE WHERE VBELN = I_INVOICE-VBELN.
ENDIF.
IF I_VBFA[] IS NOT INITIAL.
SELECT VBELN BSTNK FROM VBAK INTO CORRESPONDING FIELDS OF TABLE I_ORDER
FOR ALL ENTRIES IN I_VBFA WHERE VBELN = I_VBFA-VBELV.
ENDIF.
IF I_INVOICE[] IS NOT INITIAL.
SELECT POSNR MATNR ARKTX FKIMG NETWR FROM VBRP INTO TABLE I_ITEM FOR ALL
ENTRIES IN I_INVOICE WHERE VBELN = I_INVOICE-VBELN.
ENDIF.
LOOP AT I_ITEM.
AT LAST.
SUM.
VAR1 = I_ITEM-NETWR.
ENDAT.
ENDLOOP.
CALL FUNCTION '/1BCDWB/SF00000223'
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS =
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS =
USER_SETTINGS = 'X'
var = VAR1
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO =
JOB_OUTPUT_OPTIONS =
tables
i_vbrk = I_INVOICE
i_vbak = I_ORDER
i_vbrp = I_ITEM
i_kna1 = I_ADDRESS
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
106 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.